Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi everyone,I have a queryselect salesId,count(*) from salesline group by salesidResult will besalesid Nos----- ---SO001 2SO002 4i want to display single record like below if there is no record avaible in the tablesalesid NosSo00? 0Please helpThanks and regards,Thiya.t
TG
Master Smack Fu Yak Hacker
6065 Posts
Posted - 2014-04-25 : 10:20:31
you'd have to do something like this:
if exists(select 1 from salesline)begin select salesId,count(*) as Nos from salesline group by salesidendelsebegin select 'So00?' as salesID, 0 as Nosend