Web Analytics Made Easy -
StatCounter SQL SERVER - Nvarchar query issue - CodingForum


No announcement yet.

SQL SERVER - Nvarchar query issue

  • Filter
  • Time
  • Show
Clear All
new posts

  • SQL SERVER - Nvarchar query issue

    Hi guys

    I hope this is someting you can help me with

    Basically, I'm looking to query my sql server database using the following query

    SELECT MIN(mileage) AS minmileage, MAX(mileage) AS maxmileage
    FROM mytable
    where make = 'audi'
    and mileage > 10000"

    So I simply want to display the lowest mileage that's higher than 1000 in my database. However, the problem I have is that the "mileage" column in my table has a nvarchar format (don't ask) and I'm not able to change the format of the field.

    However, I understand I can do this via the query (CAST or Convert???).

    I have looked at so many articles but I just can't get anything to work. I get results but not as I would expect. For example, I'm getting strange results where the minmileage value for an Audi is 100000 when I know there are Audis with mileages around 25000.

    Any help would be fully appreciated

    Best regards

    Rod from the UK

  • #2
    thread has been moved to the correct forum. Was incorrectly posted under MySQL.