Simple query

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2008
Posts: 1
Reputation: dave.respawn is an unknown quantity at this point 
Solved Threads: 0
dave.respawn dave.respawn is offline Offline
Newbie Poster

Simple query

 
0
  #1
May 5th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 97
Reputation: manoshailu is an unknown quantity at this point 
Solved Threads: 10
manoshailu's Avatar
manoshailu manoshailu is offline Offline
Junior Poster in Training

Re: Simple query

 
0
  #2
May 6th, 2008
hi,

Try the Below Query:

  1. SELECT c.cat_name,sum(PI.item_price * PI.item_qty) as total, c.c_vat_rate * total
  2. FROM category c , purchase p,puchase_item PI,country co,seller s
  3. WHERE p.p_id=PI.p_id AND c.cat_id=PI.cat_id AND total>100
  4. AND co.c_id=s.c_id AND s.seller_id=p.seller_id
  5. 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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for MS SQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC