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
 need of query

Author  Topic 

vidhya
Posting Yak Master

108 Posts

Posted - 2008-09-30 : 07:39:36
i am using 3 tables
namely kr_reference,kr_referencerating,kr_referencehistory.

In kr_reference table i m having column -->refid
in kr_referencerating table i m having--> ratid,refid,points
in kr_referencehistory table i m having -->lid,refid,title

From this table i need to display the title and total sum of points corresponding to the refids.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-30 : 07:52:06
Use JOINs between tables.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

vidhya
Posting Yak Master

108 Posts

Posted - 2008-09-30 : 07:54:13
peso,

select h.title as title,sum(r.points) as total from kr_referencerating r,kr_reference f,kr_category c, kr_referencehistory h where h.refid=f.refid and f.catid=c.catid and r.refid=f.refid and r.deleted=0 group by f.refid,h.title

i used this query to display sum of points and title. i need to display ratid too.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-30 : 07:54:20
[code]SELECT rh.title,SUM(r.points) AS SumofPoints
FROM kr_referencerating r
INNER JOIN kr_referencehistory rh
ON rh.refid=r.refid
GROUP BY rh.title[/code]
Go to Top of Page
   

- Advertisement -