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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rush2hem
    New Member
    • Sep 2013
    • 1

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

    I am trying to build a query which will give me unique rows. Details:-
    Code:
    Table 1	(F1, F2 are the columns)
    F1	F2
    1	A1
    2	A2
    3	A3
    4	A4
    Table 2 (F3,F4 are the columns)
    Code:
    F3	F4
    1	B1
    1	B11
    2	B2
    2	B22
    My Query (Incorrect)
    Code:
    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:-

    Code:
    RRN	F1	F2	F3	F4
    1	1	A1  	1	B1  
    1	1	A1  	1	B11 
    2	2	A2  	2	B2  
    2	2	A2  	2	B22 
    3	3	A3  	(null)	(null)
    4	4	A4  	(null)	(null)

    Expected output that I am building query for is:-

    Code:
    RRN	F1	F2	F3	F4
    1	1	A1  	1	B1  
    2	2	A2  	2	B2  
    3	3	A3  	(null)	(null)
    4	4	A4  	(null)	(null)
    Please let me know if you have any suggestions.
    Last edited by Rabbit; Sep 7 '13, 02:52 PM. Reason: Please use code tags when posting code or formatted data.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    you should also explain why this i wrong
    Code:
    2 2 A2 2 B2 
     2 2 A2 2 B22
    and this is correct
    Code:
    2 2 A2 2 B2
    Should only the first row in Table 2 be returned?
    or the one with the shortest (in characters) F4?

    Comment

    Working...