davidc2
05-03-2007, 06:12 PM
I've been trying a lot of different ways but I have no idea how to get it to run...
Query:
create view revenue[STREAM_ID] (supplier_no, total_revenue) as
select
l_suppkey,
sum(l_extendedprice * (1 - l_discount))
from
lineitem
where
l_shipdate >= '1996-01-01'
and l_shipdate < dateadd(month, 3, '1996-01-01')
group by
l_suppkey;
select
s_suppkey,
s_name,
s_address,
s_phone,
total_revenue
from
supplier,
revenue[STREAM_ID]
where
s_suppkey = supplier_no
and total_revenue = (
select
max(total_revenue)
from
revenue[STREAM_ID]
)
order by
s_suppkey;
drop view revenue[STREAM_ID];
Error I'm getting:
Msg 102, Level 15, State 1, Procedure revenue, Line 1
Incorrect syntax near 'STREAM_ID'.
Msg 102, Level 15, State 1, Procedure revenue, Line 31
Incorrect syntax near 'STREAM_ID'.
Any suggestions?
Query:
create view revenue[STREAM_ID] (supplier_no, total_revenue) as
select
l_suppkey,
sum(l_extendedprice * (1 - l_discount))
from
lineitem
where
l_shipdate >= '1996-01-01'
and l_shipdate < dateadd(month, 3, '1996-01-01')
group by
l_suppkey;
select
s_suppkey,
s_name,
s_address,
s_phone,
total_revenue
from
supplier,
revenue[STREAM_ID]
where
s_suppkey = supplier_no
and total_revenue = (
select
max(total_revenue)
from
revenue[STREAM_ID]
)
order by
s_suppkey;
drop view revenue[STREAM_ID];
Error I'm getting:
Msg 102, Level 15, State 1, Procedure revenue, Line 1
Incorrect syntax near 'STREAM_ID'.
Msg 102, Level 15, State 1, Procedure revenue, Line 31
Incorrect syntax near 'STREAM_ID'.
Any suggestions?