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
 Creating a view called vw_ProductAverage

Author  Topic 

Arend
Starting Member

17 Posts

Posted - 2007-01-31 : 03:56:23
Hi,

I have to create a view that displays the average quantity used per invoice for each product. and substitute NULL values with zeros.

Please I need help and will appreciate any!

I have a MATERIALDETAIL table with columns invoiceID, productCode and Quantity.

THIS IS WHAT I HAVE SOFAR:
*************************
create view vw_ProductAverage
as
select distinct product_code
from materialdetail
go

select * from vw_productAverage
go

***************************

PLEASE help.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-31 : 04:00:01
create view vw_ProductAverage
as
select productcode, avg(isnull(quantity, 0.0)) as AverageQuantity
from materialdetail
group by productcode


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-31 : 04:01:35
[code]create view vw_ProductAverage
as
select productcode, invoiceID, avg(isnull(quantity, 0.0)) as AverageQuantity
from materialdetail
group by productcode, invoiceID[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -