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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 plz Help in While Loop

Author  Topic 

vedjha
Posting Yak Master

228 Posts

Posted - 2008-10-10 : 03:12:30
i have to find ID members who belongs to closing 0 to 8
and 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=8

select @directtotal=count(*) from directsppay where vspid=@uid and cclosingno=8

print @memtotal +' '+ @directtotal
end


how to show these values


Ved 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)m
join
(select vspid,count(*) as dcount
from directsppay
where cclosingno=8
group by vspid
) d
on d.vspid=m.isid
where m.isid=@uid
and m.cclosing=8
Go to Top of Page
   

- Advertisement -