sql - Oracle decode+date+single row -
I am using oracle and have details below
SQL & gt; As with T (123456 as TASK_ID ID, select 1, -1 ASSIGNED_ID, as ASSIGNED_GRP as Null, sysdate-12/24 dual union from ASSIGNED_DATE, all selected as 12345, 2,67890, Null, sysdate-11/24 Select All from Dual Union 12345,278901, Null, sysdate-10/24 Dual Union Select All 12345,2, -11111, sysdate-09 / 24 Dual Union Select All 12345,2,67890, Null, from sysdate-08 / Dual Union / 24/2 12345,2, 2, 2, 2222, all sysdate-07/24, all selected from Dual Union 12345,2, 78901 , Zero, sysdate-06/24 all selection from dual union 12346,2,67890, null, sysd All selected from the ate-05/24 dual union 12346,2, -11111, sysdate-04/24 Dual union selection of all 12346,2,67890, Null, sysdate-03/24 Dual union all 12,346 Select ID, Decoded (ASSIGNED_ID, Zero, '*', '-1', '*', ASSIGNED_ID), ASSIGNED_GRP), Select ID, Decode (ASSIGNED_GRP, Zero, Select, 2,78901, Null, sysdate-02 / Dual) From 24, ASSIGNED_DATE; ID DECODE (ASSIGNED_GRP, NULL, DECODE (Integration ASSIGNED_DATE -------- ------------------------------- --------- ----------------- 12345 * 25-APR-2014 11:33 12345 67890 25-APR-2014 12:33 12345 78 9 01 25-Apr-2013 13:33 12345 1111 25-APR-2014 14:33 12345 678 9 25 25-APR-2015 15:33 12345 2222 25-APR-2014 16:33 12345 78 9 01 25-APR-2014 17 : 33 12346 678 9 25 25-Apr-2014 18:33 12346 1111 25-APR -2014 19:33 12346 678 9 25 25 April 2014 20:33 12346 78901 25-APR -2013 21:33 I am looking for the expected output below
ID attached hours ----------------- 12345 67890 2 12345 78901 2 12345 1111 1 12345 2222 1 12346 678 9 02 2 12346 78901 2 12345 1111 1 This timeline Using the parameters, but tried to face the problem with decode function. Can you please suggest
You are counting the rows that match the conditions.
The following creates the result set you want, though different commands:
selected ID, decode (ASSIGNED_GRP, zero, decoded (ASSIGNED_ID, zero, '*', '-1', '*', ASSIGNED_ID), ASSIGNED_GRP), count (*) t where assign_grp is not empty In or (assigned_id is not empty and Assigned_id & Lt; & Gt; -1) ID, Decoded (ASSIGNED_GRP, Zero, Decode (ASSIGNED_ID, Zero, '*', '-1', '*', ASSIGNED_ID), ASSIGNED_GRP) Group by order 1, 2;
Comments
Post a Comment