| | |
Simple query
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2008
Posts: 1
Reputation:
Solved Threads: 0
Hi,
im going back through some SQL questions for my exams next week and I cant find a soloution for this, anyone help out?
Do a report using SQL that lists the names of categories from which items were bought. For each category the report should show the total value of the purchases (excluding VAT) and the total value of the VAT paid.. Exclude those categories where the total value of the purchases (excluding VAT) is less than €100.
Country(c_id, c_name, c_vat_rate, exchange_rate)
Seller(seller_id, seller_name, c_id)
Category(cat_id, cat_name)
Purchase(p_id, p_date, seller_id)
Purchase_item(p_id, item_name, cat_id, item_price, item_qty)
Fig. 1 Logical Schema
im going back through some SQL questions for my exams next week and I cant find a soloution for this, anyone help out?
Do a report using SQL that lists the names of categories from which items were bought. For each category the report should show the total value of the purchases (excluding VAT) and the total value of the VAT paid.. Exclude those categories where the total value of the purchases (excluding VAT) is less than €100.
Country(c_id, c_name, c_vat_rate, exchange_rate)
Seller(seller_id, seller_name, c_id)
Category(cat_id, cat_name)
Purchase(p_id, p_date, seller_id)
Purchase_item(p_id, item_name, cat_id, item_price, item_qty)
Fig. 1 Logical Schema
hi,
Try the Below Query:
Shailaja
Try the Below Query:
sql Syntax (Toggle Plain Text)
SELECT c.cat_name,sum(PI.item_price * PI.item_qty) as total, c.c_vat_rate * total FROM category c , purchase p,puchase_item PI,country co,seller s WHERE p.p_id=PI.p_id AND c.cat_id=PI.cat_id AND total>100 AND co.c_id=s.c_id AND s.seller_id=p.seller_id GROUP BY c.cat_name,c.vat_rate
Shailaja
Last edited by peter_budo; May 9th, 2008 at 8:03 am. Reason: Keep It Organized - please use [code] tags
![]() |
Similar Threads
- simple query about cout (C)
- Need help on query! (MySQL)
- Newbie - looping and array [very simple] problem (PHP)
- Help with simple shell script (Windows NT / 2000 / XP)
- microsoft access simple date query (Computer Science)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
- Please help me out with MySQL query (MySQL)
- DB-Authentication php/mysql on Mac OSX v3 (PHP)
Other Threads in the MS SQL Forum
- Previous Thread: Filter the Filter
- Next Thread: Simple Question PLease URGENT
| Thread Tools | Search this Thread |
Tag cloud for MS SQL
"last autogrowth business connectingtodatabaseinuse count cursor data database dateadd datepart day" dbsize deadlock delete_trigger getdate highperformancecomputing hpc hpcserver2008 ibm iis loop maximum microsoft ms mssql multiple multithreading news number permission query reporting result server services sets source sql sqlserver sqlserver2005 supercomputing tables uniqueid update view weekday





