sql - How can I prevent all Null values from being returned in this TSQL? -
i've got tsql:
select invd.unit, m.membername, invd.description invoicedetail invd left join members m on invd.memberno = m.memberno group invd.unit, m.membername, invd.description ...which works 90% of what's returned (aside being agonizingly slow), approximately 10% of returned records contain null value either invd.unit or m.membername or both.
i want records no nulls anywhere. need prevent records null values being returned in result set?
i don't want use this:
select isnull(invd.unit, 'no unit'), isnull(m.membername, 'no member name'), invd.description . . . i don't want records @ all; want unique/distinct combinations of 3 fields (excluding nulls in of them - data useful 3 values exist).
change left join inner join where condition
select invd.unit, m.membername, invd.description invoicedetail invd inner join members m on invd.memberno = m.memberno invd.unit not null , m.membername not null , invd.description not null group invd.unit, m.membername, invd.description as mentioned in comments better use distinct instead of group by make intention clear. when there no aggregate in select sql server smart enough convert group by distinct
Comments
Post a Comment