Expand|Select|Wrap|Line Numbers
- select entity, count(*) as vcnt, sum(amt) as vamt
- from vtable
- where date = @dateparm
- and rec_type = 'V'
- group by entity
- select entity, count(*) as ccnt, sum(amt) as camt
- from ctable
- where date = @dateparm
- and rec_type = 'C'
- group by entity
Before group by entity is a many to many relationship.