oracle - Basic SQL Query Construction Regarding Dates as a Parameter in Toad -


i new sql , having issues understanding if syntax. before tag duplicate, have spent quite time reading other questions similar mine.

what need sum of product produced each month between july , december of 2012 total , individual month.

my table has columns date of production , total items produced day. production date in data base stored '5/21/2013 11:23:45 am' example

table named 'first_conveyor_row'

columns named 'amnt_of_product' , prod_date

i need along lines of:

       select sum(amnt_of_product) monthlytotal first_conveyor_row        every month between july , december of 2012 

obviously second line query incorrect, conveys need.

the output im looking like:

july: 4tons

aug: 6tons

..... total 30 tons.

i can overall total easily, when try add date ranges blows on me.

any insight appreciated.

is want:

create table first_conveyor_row (   amnt_of_product number,   prod_date       date );  insert first_conveyor_row values(7, to_date('01/07/2012','dd/mm/yyyy')); insert first_conveyor_row values(4, to_date('02/07/2012','dd/mm/yyyy')); insert first_conveyor_row values(2, to_date('02/08/2012','dd/mm/yyyy')); insert first_conveyor_row values(3, to_date('04/08/2012','dd/mm/yyyy')); insert first_conveyor_row values(9, to_date('04/12/2012','dd/mm/yyyy')); insert first_conveyor_row values(6, to_date('04/01/2013','dd/mm/yyyy')); commit; 

the query is:

select to_char(prod_date, 'month') product_month, sum(amnt_of_product) monthlytotal   first_conveyor_row  prod_date between to_date('01/07/2012', 'dd/mm/yyyy') , to_date('31/12/2012', 'dd/mm/yyyy') group rollup (to_char(prod_date, 'month')) order to_date(product_month, 'month') ; 

result of query:

product_month           monthlytotal ----------------------- ------------ july                              11 august                             5 december                           9                                   25 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -