Gus_ftw Posted August 29, 2016 Share Posted August 29, 2016 (edited) Hi, i have problems to get the top 10values from a SQLite database. The first code gives me the values but I want it to be sorted like from the richest players to the poorest players with a limit of 10 player. Example. 1. 1,901,011$ 2. 1,871,110$ 3. 1,681,191$ etc. 1. code function getData( ) return dbPoll ( dbQuery ( db, "SELECT * From (Select * from data ORDER BY money desc) LIMIT 10 " ), -1 ) end setTimer(getData, 5000, 0) This is how this code returns: Edited August 30, 2016 by Guest Link to comment
Arsilex Posted August 29, 2016 Share Posted August 29, 2016 function getData( ) return dbPoll ( dbQuery ( db, "SELECT * FROM data ORDER BY money DESC LIMIT 10" ), -1 ) end setTimer(getData, 5000, 0) Link to comment
Gus_ftw Posted August 29, 2016 Author Share Posted August 29, 2016 function getData( ) return dbPoll ( dbQuery ( db, "SELECT * FROM data ORDER BY money DESC LIMIT 10" ), -1 ) end setTimer(getData, 5000, 0) It returns the same value as my code. Link to comment
Arsilex Posted August 29, 2016 Share Posted August 29, 2016 I just tried my code and this is what i get. Link to comment
Gus_ftw Posted August 29, 2016 Author Share Posted August 29, 2016 @Arsilex I don't know why mine doesn't work. I think that it might be from the datatype of the column. dbExec(db, "CREATE TABLE IF NOT EXISTS data (account TEXT, money INT)") Link to comment
GTX Posted August 29, 2016 Share Posted August 29, 2016 Column type is okay, it might be because you have those commas like 99,693,897. Link to comment
Arsilex Posted August 30, 2016 Share Posted August 30, 2016 I just saw that your image is fine but something in your database is bad because as you see the values are 99, 96, 93, 9 (90), 87, 86, 8 (80), 79 etc looks like the commas are the issue here as GTX said Link to comment
!#NssoR_) Posted August 30, 2016 Share Posted August 30, 2016 When you want to put money in the GridList then converts it to commas. Link to comment
JR10 Posted August 30, 2016 Share Posted August 30, 2016 You should not have commas in your INT-type column. Store the integers without the commas, and format it accordingly whenever you want to present it. Link to comment
Gus_ftw Posted August 30, 2016 Author Share Posted August 30, 2016 Thanks, it worked perfectly. Link to comment
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