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
 Emergency Topic 3.

Author  Topic 

tbc
Starting Member

3 Posts

Posted - 2006-12-04 : 23:13:21
I absolutely agree with you.

I managed to find the error, it was a typo.

Here is the code, if somebody is interested about it. It is oracle, not SQL server, but the idea is the same.

drop view a;
drop view b;
drop view figure5_9;

create view a
as
select d.donorID, dt.donortype, dt.donortargetq1
from donortype dt, donor d
where d.donortype=dt.donortype;

select * from a;

create view b
as
select a.donortype, sum(c.ContributionAmount) as amount
from Contribution c, a
where c.ContributionDate between '01-JAN-06' and '31-MAR-06' and a.donorID=c.donorID
group by a.donortype;

select * from b;

create view figure5_9
as
select b.donortype, a.donortargetq1, b.amount, b.amount/a.donortargetq1 as percentage
from a, b
where a.donortype=b.donortype
group by b.donortype, a.donortargetq1, b.amount;

select * from figure5_9;


Thanks for the help anyway ;-)

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-12-04 : 23:27:17
I'll give you a D minus on that one.

You should have done it in one SELECT statement, and you should have used the ANSI join syntax.

I don't think the result is correct either, but you didn't state the problem very well, so it's hard to tell.






CODO ERGO SUM
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-12-04 : 23:36:26
Let's see:

1. Twice told that we don't answer homework/assignment questions, posts a third time anyway.
2. Posts Oracle questions on a SQL Server site.

Hope your burger flipping skills are top-notch.
Go to Top of Page
   

- Advertisement -