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.
i have to find ID members who belongs to closing 0 to 8and by the differrent ID there is different query: query:::declare @memtotal int declare @directtotal int declare @uid varchar(10) select @uid=aid from members where cclosing between 0 and 8 while(@uid<='U100004432') begin select @memtotal=count(*) from members where isid=@uid and cclosing=8select @directtotal=count(*) from directsppay where vspid=@uid and cclosingno=8 print @memtotal +' '+ @directtotal endhow to show these valuesVed Prakash Jha
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2008-10-10 : 03:47:47
you need just this
select cast(m.memcount as varchar(10))+ ' '+cast(d.dcount as varchar(10))from(select isid,count(*)as memcount from members)mjoin (select vspid,count(*) as dcountfrom directsppay where cclosingno=8group by vspid) don d.vspid=m.isidwhere m.isid=@uid and m.cclosing=8