Exists SQL Statement -


i trying find year , caseseqnumbers in table type not appellant rep 1. error coming fact year , caseseqnumber can have many rows in table. have tried:

select caseseqnumber, year caseparticipants not exists (select *                   caseparticipants                   participanttype = 'appellant rep 1') 

any help?!

you join caseparticipants itself, using left join. if join doens't succeed, means caseseqnumber , year don't have row participanttype = 'appellant rep 1':

select   c1.caseseqnumber,    c1.year     caseparticipants c1 left join caseparticipants c2   on c1.year=c2.year , c1.caseseqnumber=c2.caseseqnumber      , c2.participanttype = 'appellant rep 1'   c2.year null 

edit

to compare number of distinct combinations of caseseqnumber, year, , number of combinations have a type of 'appellant rep 1' use sql server query:

select   count(distinct     cast(c1.caseseqnumber varchar) + '-' + cast(c1.year varchar)),   count(distinct     cast(c2.caseseqnumber varchar) + '-' + cast(c2.year varchar))    caseparticipants c1 left join caseparticipants c2   on c1.year=c2.year , c1.caseseqnumber=c2.caseseqnumber      , c2.participanttype = 'appellant rep 1' 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -