Please! Need help with a query...

  • Thread starter Thread starter wtbuzz
  • Start date Start date
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!!
 
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)
 
SELECT ID, NAME, CATEGORY,
IIf(CATEGORY = 1, PRICE, Null) As PRICE1,
IIf(CATEGORY = 2, PRICE, Null) As PRICE2
FROM [YourTable]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top