On Wed, 24 Jul 2013 11:38:42 +0530, Sandeep kaur <firstname.lastname@example.org
declaimed the following:
Suppose I have following table in my database :
activity1 | activity2 | activity3 | activity4 | activity5
6 | 7 | 5 | 9 | 8
The first row are the field names and the second row are the data
entries. How can I get 3 maximum values out of each row of this table?
Like from this row, I should get 7,8,9.
Eagerly waiting fro your reply.
Well, I'd start by normalizing that... One should not have repeating
groups in a relational database; it is often easier to extract data when
the "column name" is treated as a key in a two column table
Activity_Order | Activity_Value
1 | 6
2 | 7
3 | 5
4 | 9
5 | 8
Then one can do something like (SQL, not Django ORM)
select Activity_Order, Activity_Value from Activities
order by Activity_Value desc
(works with SQLite3)
Granted, to really be useful, you'll need a foreign key linking back to
the parent record:
Wulfraed Dennis Lee Bieber AF6VN email@example.com
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firstname.lastname@example.org.
To post to this group, send email to email@example.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.