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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query help

Author  Topic 

nicka
Starting Member

28 Posts

Posted - 2002-05-22 : 12:00:20
I need help in a query:

Initial table(call it tblProduct) is as follows

PRODUCT QUOTEDPRICE ORDERAMOUNT
A1 10,000 0
A1 5,000 1,000
A2 6,000 10,000

Query result should be as such

PRODUCT TIMESQUOTED QUOTEDPRICE TIMESORDERED ORDERAMOUNT
A1 2 10,000 0 0
A2 1 6,000 1 10,000

Essentially I would like to query QuotedPrice and OrderAmount (whenever they are more than 0).

Can anyone help.


M.E.
Aged Yak Warrior

539 Posts

Posted - 2002-05-22 : 12:07:42
Little bit low on time, so I don't have enough to write it out fully for you, but lookup info on groupby

select product, count(orderamount) as 'times ordered'
from prodtable
group by product

sorry if thats a little brief, just don't have much time.. group by is you key term.. lookit up

Go to Top of Page

dsdeming

479 Posts

Posted - 2002-05-22 : 14:50:40
In your example you show A1 as having been quoted twice at 10K, but the data indicates it was quoted once at 5K and once at 10K and 1K total units were ordered. This doesn't seem to jive with your desired output.

Go to Top of Page
   

- Advertisement -