I have two tables, and I want ALL the data from both. If the tables have a matching AssetID, then join them on one row. If not, then on separate rows. A full outer join sounds like the right approach but I have a problem in how to select the keys depending on which table it comes from. Goal: Produces
Tag: full-outer-join
Generate Result based on max count in secondary column after a join
I have two tables which have a common key between them, and quite a lot of other important infos ; for the sake of simplicity i will be using Combination A and Combination B. When a combination is met, whichever table has the maximum number of records should be the source where i collect the information ; in this case
merge tow querys in sql
I have a issuse in sql query. I have 2 select: The first one showing: columnA|columnB A |2 B |3 D |5 The other one showing: columnA|columnC A |1 B |5 C |7 I’m …
count(*) doesn’t return 0
i have a sql problem ,please help me this is my query select count(category_value .list_value_id) as jobs , category_type.value as category from list_values category_type full outer join params …
Evaluate Multiple conditions for same row
I have to compare 2 different sources and identify all the mismatches for all IDs Source_excel table Source_dw table Expected result I have tried the below query but it is giving only one mismatch. Actual output I understand that case expression will only check the first satisfying condition. Is there any other way I can check all the condition? Answer
Matching and unlatching records in a single table sql server
I have procedure where I am getting data from my 1st temp table like below 2nd temp table like below Now I need to join this 2 temp tables to get all matching and unmatching data .My result would be like below But I am getting only matching data.Please help how to do Answer I think that’s a full join:
How to mix left and right joins with cross reference table
I’m using Mysql. I have table A(ida) and table B(idb) and a cross reference table CR(ida, idb). I want to capture in a query the relationship between A and B (basically what’s is CR) but I also want all the rows from A and B that have no relations present in CR. To get something like this: I tried this: