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
 Easiest Help Ever: Single Table 5 Lines of code

Author  Topic 

Overclockedd
Starting Member

6 Posts

Posted - 2007-03-22 : 17:32:38
I am trying to sort out the member "Adams" from the committee members, and sum up the total amounts that were donated while he was the committee member.

The Table:

CREATE TABLE contribution_list
(contrib_date DATE NOT NULL,
donor_name VARCHAR(30) NOT NULL,
amount NUMBER(8,2),
program VARCHAR2(30),
committee_member VARCHAR2(20) NOT NULL,
PRIMARY KEY (contrib_date,donor_name,committee_member));

The Code that is giving me errors:(not a group by expression):

CREATE or REPLACE VIEW adams_conrtibution_total as
select program, committee_member, sum(amount)
from contribution_list
where committee_member = 'Adams'
group by program;

Overclockedd
Starting Member

6 Posts

Posted - 2007-03-22 : 17:40:29
Nevermind, figured it out, needed to be

CREATE or REPLACE VIEW adams_contribution_total as
select program, SUM(amount) as TotalAmount
from contribution_list
where committee_member = 'Adams'
group by program;
Go to Top of Page
   

- Advertisement -