sqlite - Sort comments by rating for the top two rows of the result and the rest by date? -


let's have table of comments, so:

--------------------------- | comment | date | rating | --------------------------- |       | 1    |      1 | --------------------------- | b       | 4    |      3 | --------------------------- | c       | 7    |      2 | --------------------------- | d       | 1    |     10 | --------------------------- | e       | 3    |     20 | --------------------------- 

i want sort table 2 rated comments appear @ top of result, independently of date, , rest of comments sorted date in descending order. results should this:

--------------------------- | comment | date | rating | --------------------------- | e       | 3    |     20 | --------------------------- | d       | 1    |     10 | --------------------------- | c       | 7    |      2 | --------------------------- | b       | 4    |      3 | --------------------------- |       | 1    |      1 | --------------------------- 

is possible?

you 2 sql-queries. first 1 selects 2 highest commands.

select comment, date, rating comments order rating desc limit 2 

and can show others , order them date. aren't saving id comments table? if yes, select id in above query , in second query select comments, ordered date, don't have id previous query.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -