SYRAU3 Posted June 26, 2012 Share Posted June 26, 2012 Hello big-minds: I have a database with single table (Main): Customer | Visit_Date | Num -------------------------------- Customer1| 1/1/2012|3 Customer2| 1/1/2012|1 Customer2| 2/1/2012|1 For example: I want the last visit date of Customer2 to be shown, so i'm trying: _SQLite_Query(-1, "SELECT ROWID,* FROM Main WHERE Customer='Customer2' AND Num='1';", $hQuery) When showing $hQuery[0] in a MessageBox it gives me the first result (1/1/2012), even when using _SQLite_FetchData, so how can i get the last result in the column (2/1/2012) ? Thanx in advanced. Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted June 26, 2012 Share Posted June 26, 2012 (edited) Try "SELECT ROWID,* FROM Main WHERE Customer='Customer2' order by Visit_Date limit 1" However it may not work well with how you formatted your dates, usually the date is better entered as yyyymmddhhss...... Edited June 26, 2012 by DicatoroftheUSA Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted June 26, 2012 Share Posted June 26, 2012 If you can't convert the database format, then I think you will have to use use _SQLite_FetchData and use autoit to analyse the date to give you the greatest value. Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
SYRAU3 Posted June 26, 2012 Author Share Posted June 26, 2012 Ah, Thank you DicatoroftheUSA, It really didn't work, still giving me the same result, so I used _SQLite_FetchData and it worked perfectly. thank you. Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted June 26, 2012 Share Posted June 26, 2012 (edited) You might want to consider revising your database anyways. If it grows to any size, it can sort much quicker in the yyyymmdd... format. Then convert it afterwords to a more common human readable form. Edited June 26, 2012 by DicatoroftheUSA Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
Spiff59 Posted June 26, 2012 Share Posted June 26, 2012 You might look at SQL's MAX() function... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now