Home » RDBMS Server » Server Administration » Many months in same query
Many months in same query [message #373441] Tue, 17 April 2001 09:26 Go to next message
Karri Lahtela
Messages: 16
Registered: November 2000
Junior Member
Hi

I have this kind of problem:
I have to take sales of last 3 months for multible part_no (each of month)(exm. Jan 100, Feb 90, Mar 80 for part_no 1) And then I have to take average of those three months for this part_no (In this example it is 90). Each of sales have they own line in sales_tab
(exm. jan-01 12345678 10.00 20.00 30.00 20.00) (date, part_no, qty_first, qty_second, qty_third, avg are columns)

-Karri

P.S. Sorry my english.
Re: Many months in same query [message #373450 is a reply to message #373441] Tue, 17 April 2001 16:35 Go to previous message
Rajeev Mancheril
Messages: 4
Registered: April 2001
Junior Member
Hi,

Sounds like you have average column
in your table.
Try out this : select sum of sales value
and average value
where your sales date range from starting date
and end date (if you can substitute starting
and ending date, else you may have to
calculate this based on current
date. For date range you can use date field
BETWEEN date1 and date2).
group by part number

SELECT part_no, sum(sales_col), sum(avg_col)
FROM your_sales_table
WHERE date_field BETWEEN date1 AND date2
GROUP BY part_no

HTH,
Rajeev. M
Previous Topic: ProC Long and Table CLOB
Next Topic: A question - need feedback
Goto Forum:
  


Current Time: Sat Jun 29 01:01:20 CDT 2024