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
 Zipcensus query trouble

Author  Topic 

sweetcapgun
Starting Member

1 Post

Posted - 2014-11-17 : 15:05:17
Having Trouble with some homework and can't get the two parts of the query to join.

Question:
For each of the customer first names that occur more than 500 times, find the average revenue (price paid) for each product category.

Here are the tuples needed:

CREATE TABLE customer (
customerid int NULL,
householdid int NULL,
gender varchar(50) NULL,
firstname varchar(50) NULL
)


CREATE TABLE orders (
orderid int NULL,
customerid int NULL,
campaignid int NULL,
orderdate date NULL,
city varchar(50) NULL,
state varchar(50) NULL,
zipcode varchar(50) NULL,
paymenttype varchar(50) NULL,
totalprice numeric(10,2) NULL,
numorderlines int NULL,
numunits int NULL
)

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-11-17 : 15:28:54
you can join on the customerid column

e.g.

select firstname
from customer c
join order o
on c.customerid = o.customerid

However, since this is homework, I think you need to take it from here (or ask your TA)
Go to Top of Page
   

- Advertisement -