tsql - Select Parent..Child records from 2 tables in one query -


i have 2 tables called yl0pf (which master or parent record) , yl1pf (which detail or child record).

they join

yl0ab=yl1ab, yl0an=yl1an, yl0as=yl1as 

and restrict records column dteinp.

there can 0 many detail records 1 master record. child records arrears records showing months payments have been missed month due

so can of course this:

select  y0.* ,         y1.*    alpsproduction..yl0pf y0         left outer join alpsproduction..yl1pf y1 on y0.l0ab = y1.l1ab                                                     , y0.l0an = y1.l1an                                                     , y0.l0as = y1.l1as   y0.dteinp = '01 jun 2015' order y0.l0ab + y0.l0an + y0.l0as ,         y1.l1ab + y1.l1an + y1.l1as ,         cast(y1.dteinp date) desc 

and put child records next repeating parent records.

but if possible extract data below:

l0as1, l0an1, l0as1, *

l1as1, l1an1, l1as1, *

l1as1, l1an1, l1as1, *

l0as2, l0an2, l0as2, *

l1as2, l1an2, l1as2, *

l1as2, l1an2, l1as2, *

l1as2, l1an2, l1as2, *

so how that?


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -