Python Forum
Sqlite3 help with descending order
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sqlite3 help with descending order
#1
Hi,
I am tring to use sqlite3 in python. So far I have got it working and can display values. However, when I try displaying it in descending order, it works with 1 digit numbers, but when a value has 2 digits, it will only count the first digit.
This is the code I use to display the values:
for row in c.execute('SELECT * FROM scores ORDER BY score1 DESC LIMIT 5'):
        print (row)
The output ends up being:
Output:
('Michael', '8') ('Jim', '2') ('Tim', '2') ('James', '2') ('Chris', '19')
However, I want it to put the highest numbers at the top and not just take the first digit into account.

Thanks.
Reply


Messages In This Thread
Sqlite3 help with descending order - by I_Am_Groot - May-17-2019, 06:09 AM
RE: Sqlite3 help with descending order - by buran - May-17-2019, 06:45 AM
RE: Sqlite3 help with descending order - by buran - May-17-2019, 07:17 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to sort values descending from a row in a dataframe using python sankarachari 1 1,453 Aug-16-2021, 08:55 AM
Last Post: jamesaarr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020