473,320 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Pleasehelp me with my problem in sql.. column to row

Hi everyone,

Can someone please help me with my problem,

I really need to solve this...

I have a table Sales....

Product | Brand | Sales | Price_1| Price_2 | Price_3
---------------------------------------------------------
Milk | Alaska | 0 | 10 | 20 | 30
Milk | Alaska | 1 | 80 | 70 | 90
Milk | Alaska | 2 | 100 | 200 | 300



I need to get the minimum and maximum sales of each Product...

sales |
------
0 |
2 |


after that I need to put their prices as before and after as a row...

just like this
salesfor 0 sales for 2
bef Price | Aft Price
-------------------------
10 | 100 <-- Price 1
20 | 200 <-- Price 2
30 | 300 <-- Price 3

I want to have an output like this

Produt |Brand |MinSales |bef Price|MaxSales |Aft Price
-----------------------------------------------------
Milk |Alaska |0 | 10 |2 |100
Milk |Alaska |0 | 20 |2 |200
Milk |Alaska |0 | 30 |2 |300





Please help me with this problem




Thnk you so much in advance for anyhelp that you can do...
Aug 22 '12 #1
1 1305
Rabbit
12,516 Expert Mod 8TB
Use a min and max aggregate query joined to the table to return the rows you need. Then use a union to normalize the data. Then finally join the result to itself on the min row to the max row.
Aug 22 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Kathy | last post by:
Hi and thanks in advance for your help! I have Access 2000. I have imported a delinited text file and now have table with one column containing 100 records. I would like to display these values in...
3
by: TPhelps | last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable datagrid that works. I want to change one of the columns to a hyperlink. The examples I find use a bound column. I...
5
by: bsandell | last post by:
Hi, I have a view that looks something like this - CREATE VIEW myview AS SELECT myudf(col1) as col1, col2, col3 FROM mytable The view has an 'INSTEAD OF' trigger on it to do the correct...
4
by: Markus Ernst | last post by:
Hi Looking for a possibility to get separate tables rendered with common column widths, I was surprised to see that this code validates: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"...
8
by: nobrow | last post by:
Okay ... Im out of practice. Is it not possible to have a 2D array where each column is of a different type, say an int and a struct*? The following seg faults for me and I cant figure out what I...
1
by: ashik478 | last post by:
Hi! I have a problem. I have a table in oracle database with one field is primary key. Now I want to insert data from Datagridview with hide column which contain not null field(this field is...
3
by: Manikandan | last post by:
Hi, I have table with three columns as below table name:exp No(int) name(char) refno(int) I have data as below No name refno 1 a 2 b 3 c
2
by: vinothrao84 | last post by:
hi, i have the 2 following table in my database. tablename : tblMutFunds code.......shortname......number......display_web G1..........Growth1......... 1...............1...
1
by: GayatriPatil | last post by:
I need to maintain an array type structure with two column for path and name. The number of rows is not known. Can any one suggest any Generic Collections available
0
by: prashantdixit | last post by:
Hi, I have beent trying importing Excel data with one column containing PDF/JPEG file name to access 2007. I have a Excel file with few columns One of the columns named as "Reference". The...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.