February 25, 2015 at 8:21 am
Hi, I have a question. Scenario is something like this. I am pasting sample data to clarify my request.
first Table(Data Already available)
Number name country
12345 A Canada
23456 B USA
34567 C Australia
45678 D Japan
56789 E India
Second Table(Data coming from automated source). As data comes in this table, I am inserting a unique id with every row programatically.
Id(PK) Number
1 34567
2 45678
3 56789
4 98989
5 76767
6 34567
7 45678
In second table only first 3, 6th and 7th records Numbers are available in first table. I want to show distinct data from second table including name and country from first Table where such information is available and other rows will come blank. Duplicate values will not be shown(6,7). This is scenario where I am totally stuck.
Result required
Number name country
34567 C Australia
45678 D Japan
56789 E India
98989- -
76767- -
Please help me in this regard
February 25, 2015 at 8:30 am
SELECT DISTINCT
t2.Number
,t1.Name
,t1.Country
FROM table2 t2
LEFT JOIN table1 t1 ON t2.Number = t1.Number;
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply