Results 1 to 2 of 2

Thread: Group BY Date Range

  1. #1

    Group BY Date Range

    Hi ,

    I need some light on the following issue..

    I have a table which has a date field proceed_data.
    This table contains about past 6 months data.

    I need to select fields from this table on a weekly basis.

    I need out put as follows

    row1- Week1 column1 column2 column 3 ...
    row2- Week2 column1 column2 column 3 ...
    row3- Week3 column1 column2 column 3 ...
    ...
    ...
    Here number of weeks = Number of rows

    Can I get using group by clause..or I need to use plsql tables ...

    Thanks in Advance


  2. #2
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Re: Group BY Date Range

    No need to use pl sql tables.
    Use the following query

    select
    trunc(CURR_DTE,'WW'),
    sum(decode((received_dte - input_dte ),0,1,0)) " 0 days" ,
    sum(decode((received_dte - input_dte ),1,1,0)) "<=1days ",
    sum(decode((received_dte - input_dte ),2,1,0)) "<=2days ",
    sum(decode((received_dte - input_dte ),3,1,0)) "<=3days ",
    sum(decode((received_dte - input_dte ),4,1,0)) "<=4days ",
    sum(decode((received_dte - input_dte ),5,1,0)) "<=5days ",
    sum(decode((received_dte - input_dte ),6,1,0)) "<=6days "
    from promise
    group by trunc(CURR_DTE,'WW')


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact