Skip to content

Tag: select

How could I use case within join and union?

I have 2 tables: Matches Rounds Inserts My query: I would like to know what places a particular team achieved (should probably use HAVING m.matchwinner = ‘fnatic’) MatchID – Team – Place 1 – fnatic – 1st 3 – fnatic – 3rd 4 – fnatic – 3rd what places …

Replacing null based on a condition

I am having a table with many columns (but posting only col1, col2, col3 here for simplified post): I want to fill null values of source _id with values from id. For example, source_id a5 row has null which has to replaced with id a1 values, subsequently, source_id a6 row having null to be replaced with a5 ro…

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 unio…