K
kbhat
This posting concerns the following tables in the database that I am
working with ---- a product table and four sales table ---- one for
each quarter [Well, this may not be the best table design, but this is
what we have in place, and it will be quite an effort to get it
changed].
The product table has information such as product name, product code,
product description etc. The sales tables have information like
product code and quarterly sales volume. Now here's the important
stuff. If a product is not sold in a particular quarter, it DOES NOT
make it to the sales table for that quarter.
I want to design a query which will provide the following information:
Product Name:
1Q Sales Volume:
2Q Sales Volume
3Q Sales Volume
4Q Sales Volume
Yearly Sales Volume
Even though this sounds so simple, I am having the hardest time
designing the SQL query. This is because of what I mentioned above
--- viz. if a product is not sold in a particular quarter, it DOES NOT
make it to the sales table for that quarter. In that case the query
should show a value of 0 for that quarter.
The queries that I am designing are either yielding only those
products that reported sales in all the quarters or they are yielding
a cartesian product of all my table entries. Any help will be
appreciated.
Thanks,
Bhat
working with ---- a product table and four sales table ---- one for
each quarter [Well, this may not be the best table design, but this is
what we have in place, and it will be quite an effort to get it
changed].
The product table has information such as product name, product code,
product description etc. The sales tables have information like
product code and quarterly sales volume. Now here's the important
stuff. If a product is not sold in a particular quarter, it DOES NOT
make it to the sales table for that quarter.
I want to design a query which will provide the following information:
Product Name:
1Q Sales Volume:
2Q Sales Volume
3Q Sales Volume
4Q Sales Volume
Yearly Sales Volume
Even though this sounds so simple, I am having the hardest time
designing the SQL query. This is because of what I mentioned above
--- viz. if a product is not sold in a particular quarter, it DOES NOT
make it to the sales table for that quarter. In that case the query
should show a value of 0 for that quarter.
The queries that I am designing are either yielding only those
products that reported sales in all the quarters or they are yielding
a cartesian product of all my table entries. Any help will be
appreciated.
Thanks,
Bhat