Mikka07
Computer
- Jun 22, 2007
- 2
Hi all
I have a problem with a complex query.
there is one price a day from every suplier in the table Prices.
PRICES
Product ID | Date | Suplier |Price
0001 | 01.01.2007 | SuplierA | 10
0001 | 01.01.2007 | SuplierB | 11
0001 | 01.01.2007 | SuplierC | 13
0001 | 02.01.2007 | SuplierA | 11
0001 | 02.01.2007 | SuplierB | 12
0001 | 02.01.2007 | SuplierC | 13
.
.
.
0002 | 01.01.2007 | SuplierA | 10
0002 | 01.01.2007 | SuplierB | 15
0002 | 01.01.2007 | SuplierB | 15
.
.
.
tab2 PRODUCTS
Product Id | Category | Quality
0001 | A | 1
0002 | A | 2
0003 | B | 1
.
.
.
i want to check price movement for the last two days and get only those records where the price changed more then 10%
The desired output format:
Product Id | Category (limited to cat A) | Quality (limited to quality 1) |Suplier | Date today | Price today | Date Yesterday | Price Yesterday | Prices Difference (>10%)
I was trying to join the table Prices and Products and on this basis create a self join, but unsuccessfully.
Any hint how to build such query would be appreciated very much.
Rgrds
I have a problem with a complex query.
there is one price a day from every suplier in the table Prices.
PRICES
Product ID | Date | Suplier |Price
0001 | 01.01.2007 | SuplierA | 10
0001 | 01.01.2007 | SuplierB | 11
0001 | 01.01.2007 | SuplierC | 13
0001 | 02.01.2007 | SuplierA | 11
0001 | 02.01.2007 | SuplierB | 12
0001 | 02.01.2007 | SuplierC | 13
.
.
.
0002 | 01.01.2007 | SuplierA | 10
0002 | 01.01.2007 | SuplierB | 15
0002 | 01.01.2007 | SuplierB | 15
.
.
.
tab2 PRODUCTS
Product Id | Category | Quality
0001 | A | 1
0002 | A | 2
0003 | B | 1
.
.
.
i want to check price movement for the last two days and get only those records where the price changed more then 10%
The desired output format:
Product Id | Category (limited to cat A) | Quality (limited to quality 1) |Suplier | Date today | Price today | Date Yesterday | Price Yesterday | Prices Difference (>10%)
I was trying to join the table Prices and Products and on this basis create a self join, but unsuccessfully.
Any hint how to build such query would be appreciated very much.
Rgrds