Syntax error on date sort

55 Views Asked by At

I am using Ultralite 12. I have a table with a date field called "Date." (I didn't name it.) I want to sort my results by this field.

The query:

SELECT * FROM ItemHistory
where itemid = 'BC-2000-005' and customerid = '227B05'

works and returns the results

HistoryType,ItemID,UM_ID,CustomerID,Date,OrderHeaderID
1,'BC-2000-005',1,'227B05',2014-11-24,'849446-1'
1,'BC-2000-005',1,'227B05',2014-12-17,'852747-1'
1,'BC-2000-005',1,'227B05',2015-01-02,'854701-1'
1,'BC-2000-005',1,'227B05',2015-02-09,'859811-1'

I want to return the top answer when the results are sorted by date (in other words, the last one).

SELECT top 1 * FROM ItemHistory
where itemid = 'BC-2000-005' and customerid = '227B05'
order by date DESC

gives me a syntax error by DESC. I've tried this as well:

SELECT top 1 * FROM ItemHistory
where itemid = 'BC-2000-005' and customerid = '227B05'
order by [date] DESC
1

There are 1 best solutions below

3
On

Try with "date". You could find more info from http://dev.cs.uni-magdeburg.de/db/sybase9/help/dbrfen9/00000010.htm