How can i use this expression in DECODE function?

My PNO table formart is
PNO PDate PCount
P001 08/27/05 09:45 20
P001 08/27/05 09:50 10
P002 08/27/05 03:40 20
P003 08/28/05 11:00 20
P003 09/28/05 10:00 20
P003 08/27/05 11:00 10
P003 09/27/05 04:00 50
I want to display total pcount for shift1(morning) and shift2(evening) & the date is 08/27/05
PNO Shift1(08/27/2005 08:00 to 12:30) Shift2(08/27/2005 02:00 to 05:30)
P001 30 0
P002 0 20
P004 10 50
So for shift1 condition is:
pdate>=08/27/2005 08:00 and pdate<=08/27/2005 12:30
So for shift2 condition is:
pdate>=08/27/2005 02:00 and pdate<=08/27/2005 05:30
If i tried to give this expression in decode function , its not working.
Please give me the sql query to solve this problem.
Millions of thanks in advacne

forgot to paste the output for a given date.
SQL> create table pno
  2  (pno    varchar2(32)
  3  ,pdate  date
  4  ,pcount number)
  5  /
Table created.
SQL>
SQL> insert into pno values('P001', to_Date('08/27/05 09:45', 'mm/dd/yy hh:mi') ,20)
  2  /
1 row created.
SQL> insert into pno values('P001', to_Date('08/27/05 09:50', 'mm/dd/yy hh:mi') ,10)
  2  /
1 row created.
SQL> insert into pno values('P002', to_Date('08/27/05 03:40', 'mm/dd/yy hh:mi') ,20)
  2  /
1 row created.
SQL>
SQL> insert into pno values('P003', to_Date('08/28/05 11:00', 'mm/dd/yy hh:mi') ,20)
  2  /
1 row created.
SQL> insert into pno values('P003', to_Date('09/28/05 10:00', 'mm/dd/yy hh:mi') ,20)
  2  /
1 row created.
SQL> insert into pno values('P003', to_Date('08/27/05 11:00', 'mm/dd/yy hh:mi') ,10)
  2  /
1 row created.
SQL> insert into pno values('P003', to_Date('09/27/05 04:00', 'mm/dd/yy hh:mi') ,50)
  2  /
1 row created.
SQL> select pno,sum(pcount) "Morning Shift Count"
  2  from pno
  3  where to_char(pdate, 'mm/dd/yyyy hh:mi') >= '08/27/2005 08:00'
  4    and to_char(pdate, 'mm/dd/yyyy hh:mi') <='08/27/2005 12:30'
  5  group by pno
  6  /
PNO                              Morning Shift Count                           
P001                                              30                           
P003                                              10                           
SQL> select pno,sum(pcount) "Evening Shift Count"
  2  from pno
  3  where to_char(pdate, 'mm/dd/yyyy hh:mi') >= '08/27/2005 02:00'
  4    and to_char(pdate, 'mm/dd/yyyy hh:mi') <='08/27/2005 05:30'
  5  group by pno
  6  /
PNO                              Evening Shift Count                           
P002                                              20                           

Similar Messages

Maybe you are looking for

  • FM for Products releated to a Category

    Hi All, Can anyone of you tell me the Function Module to retrieve the list of Products if a Product Category is specified, like in that what we search in COMMPR01 transaction. Regards, Jaggu

  • I need help updating music on my new version of iTunes, anyone know how to? for iPhone 4

    i have downloaded the latest version of itunes on my laptop and i want to burn the music on it and uprgrade it so does anyone know how to? on the old itunes version was just simply an update button at the bottom right hand corner of the screen? any h

  • Updating taking hours

    Well I had the old blackberry software the 7.0 and the I seen there was an update so I done it through the app on the phone 'it was pre-installed' and it said it may take up to two hours to complete two hours went past and It was still on 17% so I di

  • Good online stores to order spare parts?

    I need to replace the rear processor cage fan because it's noisy. I have searched the Internet for online stores that sell spare parts for Mac computers (specifically 2010 Mac Pro Quad Core 2.8) and... let's say the stores I have found do not appear

  • Pseudo

    Hi, I have the following query: SELECT e.emp_id emp_no, e.emp_name emp_name, eop.ep_hourly_rate hr_rate, ou.ou_name org_unit, count(eoa.ea_emp_id) no_activities, sum(eoa.ea_planned_hours) planned_hours, sum(eoa.ea_planned_hours) * eop.ep_hourly_rate