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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 suggestion for cursor removal

Author  Topic 

spock
Starting Member

35 Posts

Posted - 2001-12-19 : 23:34:59
Hi

I have to generate a report.The table structures goes like this.
There is a master organisation table.
There is a country table which lists out all the given countries where the organisation has a presence.
There is an employee table which lists all employees , a rater table which has lists only employees who can rate employees and reviewer tables which lists all the raters and their corresponding reviewer.

The report that needs to be generated is of this format (something like a drill down but links need not be functional)

Organisation
Country (for each country in the organisation)
department (for each department in the country)
reviewer (for each reviewer in the dept)
rater (for each raters under the reviewer)
ratings (all the raters' ratings)

e.g

orgn x
USA
dept y
reviewer1
rater11
good 2
bad 3
rater12
good 2
bad 3
reviwer2
rater21
good 2
bad 3
rater22
good 2
bad 3
dept2
reviewer4
rater41 and so on....

Hope i am clear with my specs.

I used cursors to implement the above and i know lots of you would not approve of it. i would like to know how to avoid using cursors but still acheive the given requirement.

Thanks






Nazim
A custom title

1408 Posts

Posted - 2001-12-19 : 23:56:19
select o.organizationcode,countrycode,deptno,reviewercode,ratercode,
sum(ratings)
from organization o
inner join country c
on o.organzationcode=c.organizationcode
inner join department d
on c.countrycode=d.countrycode
inner join review r
on d.deptno=r.deptno
inner join rater ra
on r.reviewercode=ra.reviewercode


use any standard reporting tool(like crystal reports) and format it.

HTH

-------------------------
"Success is when Preparedness meets Opportunity"
Go to Top of Page
   

- Advertisement -