jeudi 2 juillet 2015

Sort by date + pull up by boolean

I have items in a sqlite database. Each item has a date, written in the format: YYYY-MM-DD. Of course, several items can have the same date.

Also, the items have the boolean "new". I would like to sort these items by date, with a sql query such as:

ORDER BY date DESC

That's easy. Now, I would like to pull up the items with the boolean new set to True. What I would like is, if two items have the same date, but one is new and the other is not, the new one must be returned first.

Right now, if two items have the same date, they are returned randomly sorted (or sorted on their primary index key, I don't know).

I don't know if I'm crystal clear.

Is there a way to do that ?

Aucun commentaire:

Enregistrer un commentaire