Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2012

    Unanswered: SQL Convert error

    Hi all,

    Hope your well, I have a query which runs find and resultas are as they should be however I need to join in another table to pull in a field. But I keep getting multiple rows returned or an error. So I decided to use a sub query but now I keep getting

    Incorrect syntax near the keyword 'CONVERT'.

    (SELECT MAX(LastDtm) FROM Viewtrips T WHERE A.Nameid = T.Nameid)
    CONVERT(VARCHAR(10), T.LastDtm, 120) AS [LastDtm1],

    A.Nameid is another table /ref

    Contents of Viewtrips below...
    2009-03-16 12:22:00.000

    Any pointer to where I am going wrong would be great?? I just need to get LastDtm from Viewtrips.

    Thanks for looking - Merry Xmas

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    that syntax is really messed up, and you're missing the other table in your FROM clause
    SELECT MAX(T.LastDtm) 
         , CONVERT(VARCHAR(10), MAX(T.LastDtm), 120) AS [LastDtm1]
      FROM Viewtrips T 
      JOIN Another A
        ON A.Nameid = T.Nameid
    that's not quite finished, but i couldn't guess at the rest of the query

    oh, and by the way, you posted in the mysql forum, whereas you're obviously running sql server | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    I can move the thread from MySQL - dBforums to Microsoft SQL Server - dBforums easily enough.

    The USB adapter for my Crystal Ball isn't working right today, so I'm not able to figure out the missing pieces of the query either. Maybe UnknownUser can give us hints on the schema that will let us help more!

    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts