Skip to content
Advertisement

Tag: sql-order-by

SQL’s union default order by clause?

I noticed when I am combining two tables via union that the order is not what I expected. calculus_class stats_class When I combine the two tables above I expect the results to be in order from top to bottom like this: This is the result I received using DBeaver PostgreSQL: Answer Actually, you are using union which removes duplicates, but

Order SQL results with sticky item

Is there a way to order results alphabetically and by country code, but making one result stick at the top for each country code? For example, this order: would currently display as; I’d like to be able to order the results first by country (GB first), then for GB have Oxford at the top of the list, with any additional

Advertisement