Please! Need help with a query...

W

wtbuzz

Hello!

I have a table which looks like this:

ID NAME CATEGORY PRICE
== ==== ======== =====
1 abc 1 10,00
2 def 2 20,00

How can I create a query which will show the price for items that
belong to category 2 in another column?
I mean a query which will look like this:

ID NAME CATEGORY PRICE1 PRICE2
== ==== ======== ====== ======
1 abc 1 10,00
2 def 2 20,00

Thanks!!
 
D

Dennis

Not sure why you would want to do this in a query but it is possible
Price1 and Price2 columns to look like this

Price1: iif([Category] <> 2 , [Price] , Null)
Price2: iif([Category] = 2 , [Price] , Null)
 
V

Van T. Dinh

SELECT ID, NAME, CATEGORY,
IIf(CATEGORY = 1, PRICE, Null) As PRICE1,
IIf(CATEGORY = 2, PRICE, Null) As PRICE2
FROM [YourTable]
 
T

TomHinkle

try a 'crosstab' query..

Use the query wizard... category will be the column field..
 
Top