complex data requirement.
        Posted  
        
            by 
                Abulalia
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Abulalia
        
        
        
        Published on 2011-03-08T00:00:55Z
        Indexed on 
            2011/03/08
            0:10 UTC
        
        
        Read the original article
        Hit count: 128
        
tsql
Here is my query:
select 
Table1.a,
Table1.b,
Table1.c,
Table1.d,
Table2.e,
Table3.f,
Table4.g,
Table5.h
from Table1
left join Table6 on Table1.b=Table6.b
left join Table3 on Table6.j=Table3.j
left join  Table7 on Table1.b=Table7.b
left join Table5 on Table7.h=Table5.h
inner join Table4 on Table1.k=Table4.k
inner join Table2 on Table1.m=Table2.m
where
Table2.e <= x
and Table2.n = y
and Table3.f in (‘r’, ‘s’) 
and Table1.d = z
group by
Table1.a,
Table1.b,
Table1.c,
Table1.d,
Table2.e,
Table3.f,
Table4.g,
Table5.h
order by
Table1.a,
Table1.b,
Table1.c
I am looking for records (a,b,c,d,e,f,g,h) for every a when the very first record b (there are multiple records b for each a) is either 'r' or 's'. Can someone help?
© Stack Overflow or respective owner