|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Using TOPCan someone tell me where my syntax is wrong in the following SQL statement.
It's something to do with the use of the TOP keyword: SELECT distinct top 1 * from calldetails order by calldate desc I am trying to order the table by calldate and them select the most recent record. Many thanks. What good is a Distinct when you are already using TOP 1? You will only get
one row. -- Show quoteAndrew J. Kelly SQL MVP "Andrew Chalk" <ach***@magnacartasoftware.com> wrote in message news:%23aSv7DtIGHA.1188@TK2MSFTNGP14.phx.gbl... > Can someone tell me where my syntax is wrong in the following SQL > statement. It's something to do with the use of the TOP keyword: > > SELECT distinct top 1 * from calldetails order by calldate desc > > I am trying to order the table by calldate and them select the most recent > record. > > Many thanks. > Hi,
Andrew Chalk wrote: > SELECT distinct top 1 * from calldetails order by calldate desc There is no syntax error in the above. If this is producing some sort of an error, my best guess would be you don't have a table named "calldetails" or a column named "calldate". Also, if you are executing this query from client-side code, perhaps there is some issue with that. As another poster noted, DISTINCT is totally poinless here. However, it does not cause an error. -- Chris Priede My mistake. I was connected to mySQL at the time, which doesn't support (the
nonstandard) TOP. - A Show quote "Andrew Chalk" <ach***@magnacartasoftware.com> wrote in message news:%23aSv7DtIGHA.1188@TK2MSFTNGP14.phx.gbl... > Can someone tell me where my syntax is wrong in the following SQL > statement. It's something to do with the use of the TOP keyword: > > SELECT distinct top 1 * from calldetails order by calldate desc > > I am trying to order the table by calldate and them select the most recent > record. > > Many thanks. > |
|||||||||||||||||||||||