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 me

Author  Topic 

vedjha
Posting Yak Master

228 Posts

Posted - 2008-11-13 : 10:10:34
I have to fetch ID from members table
and compare it with existing table
as

declare @ids varchar(10)
select @ids=aid from members where cstatus='V' and aid like 'U%'

using these ID satisfy condition and get result

select count(ipoint) from members m join login l
on m.aid=l.aid join scratch s
on m.aid=s.vat_id join package p
on s.vpackage=p.vpackage
where m.aid like 'U%' and dtdoj between '06/26/2008' and '07/25/2008'
and isid=@ids






Ved Prakash Jha

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-13 : 10:15:20
isnt just this enough?
select count(ipoint) 
from members m
join login l
on m.aid=l.aid
join scratch s
on m.aid=s.vat_id
join package p
on s.vpackage=p.vpackage
where m.aid like 'U%'
and dtdoj between '06/26/2008' and '07/25/2008'
and cstatus='V'
Go to Top of Page

vedjha
Posting Yak Master

228 Posts

Posted - 2008-11-13 : 10:17:58
NO

have to check by ID
it will show total points.
Findd the points;
group by isid

Ved Prakash Jha
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-13 : 10:21:05
[code]select m.isid,count(ipoint)
from members m
join login l
on m.aid=l.aid
join scratch s
on m.aid=s.vat_id
join package p
on s.vpackage=p.vpackage
join (select aid from members where cstatus='V' and aid like 'U%') m1
on m1.aid=m.isid
where m.aid like 'U%'
and dtdoj between '06/26/2008' and '07/25/2008'
group by m.isid
[/code]
Go to Top of Page

vedjha
Posting Yak Master

228 Posts

Posted - 2008-11-13 : 10:25:12
thank.... :)

Ved Prakash Jha
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-13 : 10:27:25
welcome
Go to Top of Page
   

- Advertisement -