By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,743 Members | 804 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,743 IT Pros & Developers. It's quick & easy.

Unique Rows using Left outer- I am trying to build a query which will give me unique

P: 1
I am trying to build a query which will give me unique rows. Details:-
Expand|Select|Wrap|Line Numbers
  1. Table 1    (F1, F2 are the columns)
  2. F1    F2
  3. 1    A1
  4. 2    A2
  5. 3    A3
  6. 4    A4
Table 2 (F3,F4 are the columns)
Expand|Select|Wrap|Line Numbers
  1. F3    F4
  2. 1    B1
  3. 1    B11
  4. 2    B2
  5. 2    B22
My Query (Incorrect)
Expand|Select|Wrap|Line Numbers
  1. select rrn(A), F1,F2,F3,F4 from rush2hem1.T1 A left outer join rush2hem1.T2 B on A.F1=B.F3
This gives me below output which is not what I am looking for:-

Expand|Select|Wrap|Line Numbers
  1. RRN    F1    F2    F3    F4
  2. 1    1    A1      1    B1  
  3. 1    1    A1      1    B11 
  4. 2    2    A2      2    B2  
  5. 2    2    A2      2    B22 
  6. 3    3    A3      (null)    (null)
  7. 4    4    A4      (null)    (null)

Expected output that I am building query for is:-

Expand|Select|Wrap|Line Numbers
  1. RRN    F1    F2    F3    F4
  2. 1    1    A1      1    B1  
  3. 2    2    A2      2    B2  
  4. 3    3    A3      (null)    (null)
  5. 4    4    A4      (null)    (null)
Please let me know if you have any suggestions.
Sep 7 '13 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 1,035
you should also explain why this i wrong
Expand|Select|Wrap|Line Numbers
  1. 2 2 A2 2 B2 
  2.  2 2 A2 2 B22 
and this is correct
Expand|Select|Wrap|Line Numbers
  1. 2 2 A2 2 B2 
Should only the first row in Table 2 be returned?
or the one with the shortest (in characters) F4?
Sep 7 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.