A separate city query sql

0

My sales chart marks: city for which the sale was made, date and time of sale.
I would like to pull all sales sorted by date and time, but with a specific city separately. For example:
Sale 12 - Brasilia - 2017-05-29 10:00:00
Sale 20 - Brasilia - 2017-05-29 11:00:00
Sale 31 - Brasilia - 2017-05-29 12:00:00

And then all other sales of all other cities sorted by date.

    
asked by anonymous 29.05.2017 / 16:07

2 answers

3

Simple, just use where for the desired city and order by to sort by date if you want to select data only from a city.

Select * from SuaTabela where colunaCidade = "Brasilia" order by colunaData

to select all data and sort first by a specific city:

Select * from SuaTabela order by (colunaCidade = "Brasilia") desc,colunaData
    
29.05.2017 / 16:11
-2

You will need two queries, one with city = 'brasilia' and another with city < > 'brasilia'. And join the two with UNION.

    
29.05.2017 / 16:27