Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: subtotaling by weekly
You should probably use a date column for date information. With a
single date column you can use to_char to extract data by day of the
week, Month, year, or any other piece of information contained in a
date column (date + time).
To sum data by a column value you normally use the GROUP BY clause. See the SQL manual. Image a table with a row for each paycheck an employee received for the last year.
select employee, sum(paycheck_amount)
from employee_pay_records
group by employee
The query would produce one row per employee with the total of all their paychecks.
You can use multiple aggregate functions: min, max, sum, avg in a single pass.
HTH -- Mark D Powell -- Received on Wed Mar 01 2006 - 13:30:47 CST
![]() |
![]() |