SQL Query - Mapping Groups to Batches

I am using Oracle 11g Release 2.
I have the following dataset:
CREATE TABLE RoomGroups
(group_id NUMBER,
group_name VARCHAR2(30),
group_capacity NUMBER);
INSERT INTO RoomGroups VALUES(1, 'SEECS UG Block', 100);
INSERT INTO RoomGroups VALUES(2, 'IAEC Building', 70);
INSERT INTO RoomGroups VALUES(3, 'RIMMS Building', 90);
Commit;
CREATE TABLE DegreeBatches
(batch_id NUMBER, batch_name VARCHAR2(30), batch_strength NUMBER);
INSERT INTO DegreeBatches VALUES(10,'BIT-10',35);
INSERT INTO DegreeBatches VALUES(20,'BIT-11',40);
INSERT INTO DegreeBatches VALUES(30,'BSCS-2',35);
INSERT INTO DegreeBatches VALUES(40,'BSCS-3',40);
INSERT INTO DegreeBatches VALUES(50,'BEE-4',50);
INSERT INTO DegreeBatches VALUES(60,'BICSE-7',25);
INSERT INTO DegreeBatches VALUES(70,'BESE-3',30);
Commit;
I want to achieve the following thr single or multiple SQL queries:
Firstly, get all possible sets of DegreeBatches for each group - in such a way that for each set the SUM(batch_strength) <= Capacity of that group as show below.
GroupId     Batches     StrengthStr     StrengthTotal     Capacity
1.     {BIT-10, BIT-11, BICSE-7}     {35, 40, 25}     100     100
1.     {BSCS-2, BSCS-3, BICSE-7}     {35, 40, 25}     100     100
1.     {BEE-4, BSCS-3}     {50, 40}     90     100
2.     {BIT-10, BSCS-2}     {35, 35}     70     70
2.     {BSCS-3, BESE-3}     {40, 30}     70     70
2.     {BIT-11, BICSE-7}     {40, 25}     65     70
and so on...
Secondly, I want to retrieve only non-overlapping sets based on minimum value of Capacity-StrengthTotal for each group
GroupId     Batches     StrengthStr     StrengthTotal     Capacity
1.     {BIT-10, BIT-11, BICSE-7}     {35, 40, 25}     100     100
2.     {BSCS-3, BESE-3}     {40, 30}     70     70
3.     {BSCS-2, BEE-4}     {35, 50}     85     90
And finally, the final result must have all the batches in it...
Which in this case is true...
Any help will be highly appreciated...
Thanks
Bilal

Is this not a duplicate thread?
Re: SQL Query for mapping a set of batches to a class rooms group

Similar Messages

  • SQL query using Group by and Aggregate function

    Hi All,
    I need your help in writing an SQL query to achieve the following.
    Scenario:
    I have table with 3 Columns. There are 3 possible values for col3 - Success, Failure & Error.
    Now I need a query which can give me the summary counts for distinct values of col3 for each GROUP BY of col1 and col2 values. When there are no values for col3 then it should return ZERO count.
    Example Data:
    Col1 Col2 Col3
    abc 01 success
    abc 02 success
    abc 01 success
    abc 01 Failure
    abc 01 Error
    abc 02 Failure
    abc 03 Error
    xyz 07 Failure
    Required Output:
    c1 c2 s_cnt F_cnt E_cnt (Heading)
    abc 01 2 1 1
    abc 02 1 1 0
    abc 03 0 0 1
    xyz 07 0 1 0
    s_cnt = Success count; F_cnt = Failure count; E_cnt = Error count
    Please note that the output should have 5 columns with col1, col2, group by (col1,col2)count(success), group by (col1,col2)count(failure), group by (col1,col2)count(error)
    and where ever there are NO ROWS then it should return ZERO.
    Thanks in advance.
    Regards,
    Shiva

    Hi,
    user13015050 wrote:
    Thanks TTT. Unfortunately I cannot use this solution because I have huge data for this.T's solution is basically the same as mine. The first 23 lines just simulates your table. Since you actually have a table, you would start with T's line 24:
    SELECT col1 c1, col2 c2, SUM(decode(col3, 'success', 1, 0)) s_cnt, ...
    user13015050 wrote:Thanks a lot Frank. It helped me out. I just did some changes to this as below and have no issues.
    SELECT     col1
    ,     col2
    ,     COUNT ( CASE
              WHEN col3 = 'SUCCESS'
              THEN 1
              END
         )          AS s_cnt
    ,     COUNT ( CASE
              WHEN col3 = 'FAILED'
              THEN 1
              END
         )          AS f_cnt
    ,     COUNT ( CASE
              WHEN col3 = 'ERROR'
              THEN 1
              END
         )          AS e_cnt
    FROM     t1
    WHERE c2 in ('PURCHASE','REFUND')
    and c4 between to_date('20091031000000','YYYYMMDDHH24MISS') AND to_date('20100131235959','YYYYMMDDHH24MISS')
    GROUP BY c1, c2
    ORDER BY c1, c2;
    Please let me know if you see any issues in this query.It's very hard to read.
    This site normally compresses spaces. Whenever you post formatted text (such as queries or results) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    Also, post exactly what you're using.  The code above is SELECTing col1 and col2, but there's no mention of either in the GROUP BY clause, so I don't believe it's really what you're using.
    Other than that, I don't see anything wrong or suspicious in the query.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • SQL query to group data by Code and dates

    Hi There,
    I have the following table structure
    col1 col2 col3
    code1 21-jan-2012 tested
    code1 20-jan-2012 tested
    code1 01-jun-2012 tested
    code2 01-jun-2012 tested
    code3 04-jun-2012 tested
    so on
    The output should be some thing like
    code Week1 week2 week 3 week4 week5 till about last 14 weeks from the date we are running
    code1 1 0 0 0 0
    code2 1 0 0 0 0
    code 3 0 1 0 0 0
    where 1, 0 is actually the counts and not sum and the week in this case, should have maybe been since we are in the second week it should have been
    code .....................week3 may week4 may week1 jun week2june
    Was looking for suggestions on how to get this done.
    I am assuming this would require some sort of a pivot query?
    Thanks,
    Sun

    Hi, Sun,
    sun1977 wrote:
    Thanks EKH,
    Yes, in lines of the output of this query. Is it possible to,
    1. In the query, if condition is met, the it simply displays 1 else 0. Basically, we need to get the count of the number of the codes in that week. So if code 1 happened 5 times, it should show 5.Sure; use COUNT instead of MAX.
    2. Provide the output between two dates. Lets say, I have to do it for the last 14 weeks from sysdate. Then will the logic of week1 = 1 work?Use date arithmetic to get the number of days between the starting date and col2, then divide by 7 to get the number of weeks. Use that number instead of the value returned by TO_CHAR.
    3. any suggestions if the counts have to be changed to percentages. How can we have the percentage value showingYou can do that. Exactly how depends on exactly what you want. It may involve using the analytic RATIO_TO_REPORT function in a sub-query. Post the exact results you want from the sample data that Ekh posted (or new sample data that you post), and explain how you get those results from that data.
    4. Would we also be able to add a date bind value. Lets say, if the user selects start date as may, 1st, 2012 and end date as jun5th. It sort of shows the same data but in weekly format for the weeks between the period selected?Sure, just use those values in a WHERE clause. The output needs to have a fixed number of columns, however. Say that number is 14. You can give a range that only covers 5 weeks, but the output will have 9 0's at the end of every row. You can give a range that covers 15 or more weeks, but the weeks after 14 will not be shown. To get around that requires dynamic SQL (if you want each week in a real column) or string aggregation. See {message:id=3527823}
    Point 3 is different from point 1 as in, the first one would be maybe using your logic but hardcoding for 14 weeks. Point three would be a little more dynamic.
    Thanks for your time.
    Sun
    Edited by: sun1977 on Jun 7, 2012 2:28 AM
    EXEC  :start_dt_txt := '01-May-2012';
    EXEC  :end_dt_txt   := '05-Jun-2012';
    WITH  got_week_num  AS
         SELECT  col1, col2
         ,     1 + FLOOR ( (col2 - TO_DATE (:start_dt_txt, 'DD-Mon-YYYY'))
                         / 7
                     )     AS week_num
         FROM    t
         WHERE     col2     >= TO_DATE (:start_dt_txt, ':DD-Mon-YYYY')
         AND     col2     <  TO_DATE (:end_dt_txt,   ':DD-Mon-YYYY') + 1
    SELECT       col1
    ,       COUNT (CASE WHEN week_num =  1 THEN 1 END)     AS week_1
    ,       COUNT (CASE WHEN week_num =  2 THEN 1 END)     AS week_2
    ,       COUNT (CASE WHEN week_num =  3 THEN 1 END)     AS week_3
    ,       COUNT (CASE WHEN week_num =  4 THEN 1 END)     AS week_4
    ,       COUNT (CASE WHEN week_num =  5 THEN 1 END)     AS week_5
    ,       COUNT (CASE WHEN week_num =  6 THEN 1 END)     AS week_6
    ,       COUNT (CASE WHEN week_num = 14 THEN 1 END)     AS week_14
    FROM       got_week_num
    GROUP BY  col1
    ORDER BY  col1
    ;Edited by: Frank Kulash on Jun 7, 2012 5:53 AM

  • SQL Query for mapping a set of batches to a class rooms group

    Hi All,
    I am using Oracle 11g Release 2 database.
    I have the following data set:
    ClassRooms
    ClassId ClassName                    Capacity     Group
    1 Babbage/Software Engg Lab          24          1
    2     Basement - PG Block               63          1
    3     Classroom 1                    56          1
    4     Classroom 10                    24          1
    5     Classroom 11                    24          1
    6     Classroom 12                    35          1
    7     Classroom 13                    42          1
    8     Classroom 14                    42          1
    9     Classroom 15                    42          1
    10     Classroom 2                    35          1
    11     Classroom 3                    35          1
    12     Classroom 4                     35          1
    13     Classroom 5                    35          1
    14     Classroom 6                    25          1
    15     Classroom 7                    25          1
    16     Classroom 8                    24          1
    17     Classroom 9                    24          1
    18     Control Sys Lab                    24          1
    19     Dig & Embd Sys Lab               20          1
    20     DSP & Comm Lab                    20          1
    21     Electromechanical System Lab     28          1
    22     Farabi/Web Tech Lab               36          1
    23     Gen Purpose Lab                    40          1
    24     Shirazi/DB Tech Lab               36          1
    25     Adv Elect Lab                    30          2
    26     Classroom 16                    42          2
    27     Classroom 17                    49          2
    28     Classroom 18                    56          2
    29     Classroom 19                    42          2
    30     Classroom 20                    49          2
    31     Classroom 21                    35          3
    32     Classroom 22                    35          3
    33     MDA Lab                         20          3
    DegreeBatches
    BatchId      BatchName Strength
    1          BIT-11          79          
    2          BIT-12          28          
    3          BS(CS)-1          35          
    4          BS(CS)-2          78          
    5          BE(SE)-1          69          
    6          BE(SE)-2          84          
    7          BE(SE)-3          64          
    8          BICSE-7          84          
    9          BICSE-8          43          
    10          BEE-1          112          
    11          BEE-2          151          
    12          BEE-3          157          
    13          BEE-4          157          
    I want to map a degree batch combination to a class rooms group in such away that they fully utilize maximum capacity of the class rooms within a group (Ideal case) or as close to it as possible. Can it be done with a SQL query?
    Any response will be highly appreciated.
    SQL Scripts to generate the required tables and populate data is below:
    CREATE TABLE ClassRooms (ClassId NUMBER, ClassName     VARCHAR2(50), Capacity NUMBER, Group NUMBER);
    INSERT INTO ClassRooms VALUES(1,'Babbage/Software Engg Lab',24,1);
    INSERT INTO ClassRooms VALUES(2,'Basement - PG Block',63,1);
    INSERT INTO ClassRooms VALUES(3,'Classroom 1',56,1);
    INSERT INTO ClassRooms VALUES(4,'Classroom 10',24,1);
    INSERT INTO ClassRooms VALUES(5,'Classroom 11',24,1);
    INSERT INTO ClassRooms VALUES(6,'Classroom 12',35,1);
    INSERT INTO ClassRooms VALUES(7,'Classroom 13',42,1);
    INSERT INTO ClassRooms VALUES(8,'Classroom 14',42,1);
    INSERT INTO ClassRooms VALUES(9,'Classroom 15',42,1);
    INSERT INTO ClassRooms VALUES(10,'Classroom 2',35,1);
    INSERT INTO ClassRooms VALUES(11,'Classroom 3',35,1);
    INSERT INTO ClassRooms VALUES(12,'Classroom 4',35,1);
    INSERT INTO ClassRooms VALUES(13,'Classroom 5',35,1);
    INSERT INTO ClassRooms VALUES(14,'Classroom 6',25,1);
    INSERT INTO ClassRooms VALUES(15,'Classroom 7',25,1);
    INSERT INTO ClassRooms VALUES(16,'Classroom 8',24,1);
    INSERT INTO ClassRooms VALUES(17,'Classroom 9',24,1);
    INSERT INTO ClassRooms VALUES(18,'Control Sys Lab',24,1);
    INSERT INTO ClassRooms VALUES(19,'Dig & Embd Sys Lab',20,1);
    INSERT INTO ClassRooms VALUES(20,'DSP & Comm Lab',20,1);
    INSERT INTO ClassRooms VALUES(21,'Electromechanical System Lab',28,1);
    INSERT INTO ClassRooms VALUES(22,'Farabi/Web Tech Lab',36,1);
    INSERT INTO ClassRooms VALUES(23,'Gen Purpose Lab',40,1);
    INSERT INTO ClassRooms VALUES(24,'Shirazi/DB Tech Lab',36,1);
    INSERT INTO ClassRooms VALUES(25,'Adv Elect Lab',30,2);
    INSERT INTO ClassRooms VALUES(26,'Classroom 16',42,2);
    INSERT INTO ClassRooms VALUES(27,'Classroom 17',49,2);
    INSERT INTO ClassRooms VALUES(28,'Classroom 18',56,2);
    INSERT INTO ClassRooms VALUES(29,'Classroom 19',42,2);
    INSERT INTO ClassRooms VALUES(30,'Classroom 20',49,2);
    INSERT INTO ClassRooms VALUES(31,'Classroom 21',35,3);
    INSERT INTO ClassRooms VALUES(32,'Classroom 22',35,3);
    INSERT INTO ClassRooms VALUES(33,'MDA Lab',20,3);
    CREATE TABLE DegreeBatches (BatchId NUMBER, BatchName VARCHAR2(50), Strength NUMBER);
    INSERT INTO DegreeBatches VALUES(1,'BIT-11',79);          
    INSERT INTO DegreeBatches VALUES(2,'BIT-12',28);          
    INSERT INTO DegreeBatches VALUES(3,'BS(CS)-1',35);          
    INSERT INTO DegreeBatches VALUES(4,'BS(CS)-2',78);          
    INSERT INTO DegreeBatches VALUES(5,'BE(SE)-1',69);          
    INSERT INTO DegreeBatches VALUES(6,'BE(SE)-2',84);          
    INSERT INTO DegreeBatches VALUES(7,'BE(SE)-3',64);          
    INSERT INTO DegreeBatches VALUES(8,'BICSE-7',84);          
    INSERT INTO DegreeBatches VALUES(9,'BICSE-8',43);          
    INSERT INTO DegreeBatches VALUES(10,'BEE-1',112);          
    INSERT INTO DegreeBatches VALUES(11,'BEE-2',151);     
    INSERT INTO DegreeBatches VALUES(12,'BEE-3',157);     
    INSERT INTO DegreeBatches VALUES(13,'BEE-4',157);     
    Best Regards
    Bilal
    Edited by: Bilal on 27-Dec-2012 09:52
    Edited by: Bilal on 27-Dec-2012 10:07

    Bilal, thanks for the nice problem! Another possibility for duplicate checking is to write a small PL/SQL function returning 1 if a duplicate id is found, then equate it to 0: 'Duplicate_Token_Found (p_str_main VARCHAR2, p_str_trial VARCHAR2) RETURN NUMBER'. This would parse the second string and might use p_str_main LIKE '%,' || l_id || ',%' for each id. Anyway the full query (without that) is given below:
    Solution with names
    SQL> WITH rsf_itm (con_id, max_weight, nxt_id, lev, tot_weight, tot_profit, path, root_id, lev_1_id) AS (
      2  SELECT c.id,
      3         c.max_weight,
      4         i.id,
      5         0,
      6         i.item_weight,
      7         i.item_profit,
      8         ',' || i.id || ',',
      9         i.id,
    10         0
    11    FROM items i
    12   CROSS JOIN containers c
    13   UNION ALL
    14  SELECT r.con_id,
    15         r.max_weight,
    16         i.id,
    17         r.lev + 1,
    18         r.tot_weight + i.item_weight,
    19         r.tot_profit + i.item_profit,
    20         r.path || i.id || ',',
    21         r.root_id,
    22         CASE WHEN r.lev = 0 THEN i.id ELSE r.nxt_id END
    23    FROM rsf_itm r
    24    JOIN items i
    25      ON i.id > r.nxt_id
    26     AND r.tot_weight + i.item_weight <= r.max_weight
    27   ORDER BY 1, 2
    28  ) SEARCH DEPTH FIRST BY nxt_id SET line_no
    29  , rsf_con (nxt_con_id, nxt_line_no, con_path, itm_path, tot_weight, tot_profit, lev) AS (
    30  SELECT con_id,
    31         line_no,
    32         To_Char(con_id),
    33         ':' || con_id || '-' || (lev + 1) || ':' || path,
    34         tot_weight,
    35         tot_profit,
    36         0
    37    FROM rsf_itm
    38   UNION ALL
    39  SELECT r_i.con_id,
    40         r_i.line_no,
    41         r_c.con_path || ',' || r_i.con_id,
    42         r_c.itm_path ||  ':' || r_i.con_id || '-' || (r_i.lev + 1) || ':' || r_i.path,
    43         r_c.tot_weight + r_i.tot_weight,
    44         r_c.tot_profit + r_i.tot_profit,
    45         r_c.lev + 1
    46    FROM rsf_con r_c
    47    JOIN rsf_itm r_i
    48      ON r_i.con_id > r_c.nxt_con_id
    49   WHERE r_c.itm_path NOT LIKE '%,' || r_i.root_id || ',%'
    50     AND r_c.itm_path NOT LIKE '%,' || r_i.lev_1_id || ',%'
    51     AND r_c.itm_path NOT LIKE '%,' || r_i.nxt_id || ',%'
    52  )
    53  , paths_ranked AS (
    54  SELECT itm_path || ':' itm_path, tot_weight, tot_profit, lev + 1 n_cons,
    55         Rank () OVER (ORDER BY tot_profit DESC) rnk,
    56         Row_Number () OVER (ORDER BY tot_profit DESC) sol_id
    57    FROM rsf_con
    58  ), best_paths AS (
    59  SELECT itm_path, tot_weight, tot_profit, n_cons, sol_id
    60    FROM paths_ranked
    61   WHERE rnk = 1
    62  ), row_gen AS (
    63  SELECT LEVEL lev
    64    FROM DUAL
    65  CONNECT BY LEVEL <= (SELECT Count(*) FROM items)
    66  ), con_v AS (
    67  SELECT  b.itm_path, r.lev con_ind, b.sol_id, b.tot_weight, b.tot_profit,
    68          Substr (b.itm_path, Instr (b.itm_path, ':', 1, 2*r.lev - 1) + 1,
    69            Instr (b.itm_path, ':', 1, 2*r.lev) - Instr (b.itm_path, ':', 1, 2*r.lev - 1) - 1)
    70             con_nit_id,
    71          Substr (b.itm_path, Instr (b.itm_path, ':', 1, 2*r.lev) + 1,
    72            Instr (b.itm_path, ':', 1, 2*r.lev + 1) - Instr (b.itm_path, ':', 1, 2*r.lev) - 1)
    73             itm_str
    74    FROM best_paths b
    75    JOIN row_gen r
    76      ON r.lev <= b.n_cons
    77  ), con_split AS (
    78  SELECT itm_path, con_ind, sol_id, tot_weight, tot_profit,
    79         Substr (con_nit_id, 1, Instr (con_nit_id, '-', 1) - 1) con_id,
    80         Substr (con_nit_id, Instr (con_nit_id, '-', 1) + 1) n_items,
    81         itm_str
    82    FROM con_v
    83  ), itm_v AS (
    84  SELECT  c.itm_path, c.con_ind, c.sol_id, c.con_id, c.tot_weight, c.tot_profit,
    85          Substr (c.itm_str, Instr (c.itm_str, ',', 1, r.lev) + 1,
    86            Instr (c.itm_str, ',', 1, r.lev + 1) - Instr (c.itm_str, ',', 1, r.lev) - 1)
    87             itm_id
    88    FROM con_split c
    89    JOIN row_gen r
    90      ON r.lev <= c.n_items
    91  )
    92  SELECT v.sol_id,
    93         v.tot_weight s_wt, v.tot_profit s_pr, c.id c_id, c.name c_name, c.max_weight m_wt,
    94         Sum (i.item_weight) OVER (PARTITION BY v.sol_id, c.id) c_wt,
    95         i.id i_id, i.name i_name, i.item_weight i_wt, i.item_profit i_pr
    96    FROM itm_v v
    97    JOIN containers c
    98      ON c.id = To_Number (v.con_id)
    99    JOIN items i
    100      ON i.id = To_Number (v.itm_id)
    101   ORDER BY sol_id, con_id, itm_id
    102  /
        SOL_ID S_WT S_PR  C_ID C_NAME          M_WT C_WT  I_ID I_NAME     I_WT I_PR
             1  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             2 BIT-11       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     4 BSCS-3       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   85     3 BSCS-2       35   35
                                                             5 BEE-4        50   50
             2  255  255     1 SEECS UG Block   100   95     4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                                                             7 BESE-3       30   30
                             2 IAEC Building     70   70     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
             3  255  255     1 SEECS UG Block   100  100     3 BSCS-2       35   35
                                                             4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   65     1 BIT-10       35   35
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
             4  255  255     1 SEECS UG Block   100  100     3 BSCS-2       35   35
                                                             4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     2 BIT-11       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   85     1 BIT-10       35   35
                                                             5 BEE-4        50   50
             5  255  255     1 SEECS UG Block   100   95     2 BIT-11       40   40
                                                             6 BICSE-7      25   25
                                                             7 BESE-3       30   30
                             2 IAEC Building     70   70     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
             6  255  255     1 SEECS UG Block   100  100     2 BIT-11       40   40
                                                             3 BSCS-2       35   35
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   65     1 BIT-10       35   35
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
             7  255  255     1 SEECS UG Block   100  100     2 BIT-11       40   40
                                                             3 BSCS-2       35   35
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     4 BSCS-3       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   85     1 BIT-10       35   35
                                                             5 BEE-4        50   50
             8  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     2 BIT-11       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   85     3 BSCS-2       35   35
                                                             5 BEE-4        50   50
             9  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   65     3 BSCS-2       35   35
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
            10  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                                                             7 BESE-3       30   30
                             2 IAEC Building     70   65     2 BIT-11       40   40
                                                             6 BICSE-7      25   25
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
            11  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                                                             7 BESE-3       30   30
                             2 IAEC Building     70   65     4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
            12  255  255     1 SEECS UG Block   100   95     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     2 BIT-11       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
            13  255  255     1 SEECS UG Block   100   95     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     4 BSCS-3       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
            14  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             2 BIT-11       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   65     3 BSCS-2       35   35
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
    98 rows selected.
    Elapsed: 00:00:01.42Edited by: BrendanP on 20-Jan-2013 11:25
    I found the regex needed to deduplicate:
    AND RegExp_Instr (r_c.itm_path || r_i.path, ',(\d+),.*?,\1,') = 0

  • Mapping Problem with Native SQL query

    My application uses a native SQL query to locate certain entities. It looks like this:
    SELECT UPLOADATTEMPTREF, STUDENTNUMBER, USERID, WORKITEMCODE, WORKITEMINSTURN, WORKITEMTITLE, MODULERUNCODE, STUDENTNAME, SUBMISSIONDEADLINE, UPLOADATTEMPTSERVERDATE, FILENAME, UPLOADCOMPLETESERVERDATE, NEWFILENAME, FILESIZE, FILEPATH, DOWNLOADSERVERDATE, MODULECODE, MODULETITLE
    FROM Submission_Attempt WHERE UPLOADATTEMPTREF IN (
    SELECT uploadAttemptRef FROM (" +<br /><br />                         "SELECT MAX(uploadAttemptRef) AS uploadAttemptRef, UserID, workItemInstUrn, " +<br /><br />                         "workItemCode FROM Submission_Attempt where workiteminsturn = ?1 " +<br /><br />                         "GROUP BY UserID, workItemInstUrn, workItemCode) Table1 ) " +<br /><br />                         "and uploadCompleteServerDate is not null;"<br />
    My expectation was that EclipseLink would be able to handle the mapping of the results to the entity quite happily. However, I get a NonSynchronizedVector of Objects - each Object representing one field of data.
    I need help with either:
    Converting the above SQL into JPQL so that I (hopefully) don't have to worry about the SQL or
    Understanding why this isn't working properly...
    Anyone able to help?
    Edited by: phunnimonkey on Nov 6, 2008 3:33 AM

    Never mind - the problem was to do with not specifying a class when creating the native query.

  • Query Skill Group - Translation Route mapping from Routing Script

    Hi,
    Is there a way we can query against the individual routing scripts and extract the PSG-TR mapping?
    In ICM we can map any particular Peripheral Skill Group (PSG) to a specific Translation Route (TR) defined on the same Peripheral Gateway through ICM routing scripts.
    The PSG and TR are both configured through ICM configuration manager and the details are stored in the ICM DB which can be queried against.
    However the mapping between the PSG and TR is done through a routing script using Script Editor.
    We would like to make an SQL query where we can see PSGs associated to a Translation route on Routing Scripts.
    Product: Unified Contact Center Enterprise (UCCE)
    Version: 8.5(4)

    Hi Gergely - how would you then query this data if you required it? Is there a way to map the PSGs to the Translation routes they are associated to?
    Thanks!

  • Issue in creation of group in oim database through sql query.

    hi guys,
    i am trying to create a group in oim database through sql query:
    insert into ugp(ugp_key,ugp_name,ugp_create,ugp_update,ugp_createby,ugp_updateby,)values(786,'dbrole','09-jul-12','09-jul-12',1,1);
    it is inserting the group in ugp table but it is not showing in admin console.
    After that i also tried with this query:
    insert into gpp(ugp_key,gpp_ugp_key,gpp_write,gpp_delete,gpp_create,gpp_createby,gpp_update,gpp_updateby)values(786,1,1,1,'09-jul-12',1,'09-jul-12',1);
    After that i tried with this query.but still no use.
    and i also tried to assign a user to the group through query:
    insert into usg(ugp_key,usr_key,usg_priority,usg_create,usg_update,usg_createby,usg_updateby)values(4,81,1,'09-jul-12','09-jul-12',1,1);
    But still the same problem.it is inserting in db.but not listing in admin console.
    thanks,
    hanuman.

    Hanuman Thota wrote:
    hi vladimir,
    i didn't find this 'ugp_seq'.is this a table or column?where is it?
    It is a sequence.
    See here for details on oracle sequences:
    http://www.techonthenet.com/oracle/sequences.php
    Most of the OIM database schema is created with the following script, located in the RCU distribution:
    $RCU_HOME/rcu/integration/oim/sql/xell.sql
    there you'll find plenty of sequence creation directives like:
    create sequence UGP_SEQ
    increment by 1
    start with 1
    cache 20
    to create a sequence, and
    INSERT INTO UGP (UGP_KEY, UGP_NAME, UGP_UPDATEBY, UGP_UPDATE, UGP_CREATEBY, UGP_CREATE,UGP_ROWVER, UGP_DATA_LEVEL, UGP_ROLE_CATEGORY_KEY, UGP_ROLE_OWNER_KEY, UGP_DISPLAY_NAME, UGP_ROLENAME, UGP_DESCRIPTION, UGP_NAMESPACE)
    VALUES (ugp_seq.nextval,'SYSTEM ADMINISTRATORS', sysadmUsrKey , SYSDATE,sysadmUsrKey , SYSDATE, hextoraw('0000000000000000'), 1, roleCategoryKey, sysadmUsrKey, 'SYSTEM ADMINISTRATORS', 'SYSTEM ADMINISTRATORS', 'System Administrator role for OIM', 'Default');
    as a sequence usage example.
    Regards,
    Vladimir

  • How to write a SQL Query without using group by clause

    Hi,
    Can anyone help me to find out if there is a approach to build a SQL Query without using group by clause.
    Please site an example if is it so,
    Regards

    I hope this example could illuminate danepc on is problem.
    CREATE or replace TYPE MY_ARRAY AS TABLE OF INTEGER
    CREATE OR REPLACE FUNCTION GET_ARR return my_array
    as
         arr my_array;
    begin
         arr := my_array();
         for i in 1..10 loop
              arr.extend;
              arr(i) := i mod 7;
         end loop;
         return arr;
    end;
    select column_value
    from table(get_arr)
    order by column_value;
    select column_value,count(*) occurences
    from table(get_arr)
    group by column_value
    order by column_value;And the output should be something like this:
    SQL> CREATE or replace TYPE MY_ARRAY AS TABLE OF INTEGER
      2  /
    Tipo creato.
    SQL>
    SQL> CREATE OR REPLACE FUNCTION GET_ARR return my_array
      2  as
      3   arr my_array;
      4  begin
      5   arr := my_array();
      6   for i in 1..10 loop
      7    arr.extend;
      8    arr(i) := i mod 7;
      9   end loop;
    10   return arr;
    11  end;
    12  /
    Funzione creata.
    SQL>
    SQL>
    SQL> select column_value
      2  from table(get_arr)
      3  order by column_value;
    COLUMN_VALUE
               0
               1
               1
               2
               2
               3
               3
               4
               5
               6
    Selezionate 10 righe.
    SQL>
    SQL> select column_value,count(*) occurences
      2  from table(get_arr)
      3  group by column_value
      4  order by column_value;
    COLUMN_VALUE OCCURENCES
               0          1
               1          2
               2          2
               3          2
               4          1
               5          1
               6          1
    Selezionate 7 righe.
    SQL> Bye Alessandro

  • Convert data link between one query's group and another querys group to SQL

    Hi
    I have a report where there are 2 query Groups. These 2 query groups r linked by data link. How do i combine these queries to One query so i can use it as a SQL query.
    Thanks

    Hi,
    Assume that we have two queries Q1 and Q2 and the common column between the two queries is "comn".
    Now we can convert the datalink into SQL as follows:-
    SELECT *
    FROM
    (Query for Q1)a,
    (Query for Q2)b
    WHERE a.comn=b.comn(+)
    Note: "a" and "b" are alias names for Q1 and Q2.

  • Displaying a radio group in SQL QUERY report region

    Good morning everyone,
    I have a report in which a column - ORDER STATUS, will come in with a value of 1, 2 or 3...being order unfilled, order partially filled, or order filled, respectively.
    I would like to display the order status as a radio group on the report so that it will be easy to run down the column of radio buttons to see what is filled, etc.
    I've gone to the manual and checked the doco on HTMLDB_ITEM.RADIOGROUP. But the example given there is actually for CHECKBOX (is this an error?!?).
    I went to the forums and found nothing suitable.
    My region is an SQL QUERY. Can I display the STATUS as a radio group in the SELECT ?
    This is the question.
    Thankyou in anticipation. TC. 23/11/2004

    Tony,
    There may be better solutions, but here's what I was thinking:    create table orders (id number, status number, customer varchar(30))
        insert into orders (id,status,customer) values(1,1,'ACME')
        insert into orders (id,status,customer) values(2,2,'BENSON')
        insert into orders (id,status,customer) values(3,3,'CLARKE')
        commit
        Query Source
        select
          id "ORDER NUMBER",
          decode(status,
            1,htmldb_item.RADIOGROUP(1,status,'1','unfilled')||htmldb_item.RADIOGROUP(2,status,'2','partial','"disabled=true"')||htmldb_item.RADIOGROUP(3,status,'3','filled','"disabled=true"'),
            2,htmldb_item.RADIOGROUP(1,status,'1','unfilled','"disabled=true"')||htmldb_item.RADIOGROUP(2,status,'2','partial')||htmldb_item.RADIOGROUP(3,status,'3','filled','"disabled=true"'),
            3,htmldb_item.RADIOGROUP(1,status,'1','unfilled','"disabled=true"')||htmldb_item.RADIOGROUP(2,status,'2','partial','"disabled=true"')||htmldb_item.RADIOGROUP(3,status,'3','filled'))
          "STATUS",
          customer "Customer Name"
        from orders;Scott

  • How can I use the Rownum/Customized SQL query in a Mapping?

    Hi,
    * I need to use a Rownum for populating one of the target field? How to create a mapping with Rownum?
    * How can I use an Dual table in OWB mapping?
    * Can I write Customized SQL query in OWB? How can I achieve this in a Mapping?
    Thanks in Advance
    Kishan

    Hi Niels,
    As I'm sure you know, the conundrum is that Reports doesn't know how many total pages there will be in the report until it is all done formatting, which is too late for your needs. So, one classical solution to this problem is to run the report twice, storing the total number of pages in the database using a format trigger, and throwing away the output from the first run when you don't know the total number of pages.
    Alternatively, you could define a report layout so that the number of pages in the output is completely predictable based upon, say, the number of rows in the main query. E.g., set a limit of one, two, ... rows per page, and then you'll know how many pages there will be simply because you can count the rows in a separate query.
    Hope this helps...
    regards,
    Stewart

  • SQL Query for members of dynamic group - Need to include Name, Path and Type

    Hello,
    I built a custom dynamic group that has all my SQL databases in it using SCOM 2012 SP1.  The group works fine as I can see the Name(ie, Database name), Health State, Path (ie, hostname/instance) and Types (ie; SQL 2005).  Now I'm trying to
    build a custom report based off this same information using a SQL query.   I'm no DBA and could use some help.  So far this is what i have
    use
    select
    SourceObjectDisplayName as
    'Group Name',
    TargetObjectDisplayName,TargetObjectPath
    from RelationshipGenericView
    where isDeleted=0
    AND SourceObjectDisplayName
    like
    'SQL_Databases_All'
    ORDERBY TargetObjectDisplayName
    This gets me the Group Name (which i really don't care about), database name, and hostname/instance. What I am missing is the Health State and most importantly the Type (ie, SQL Server 2005 DB, SQL Server 2008DB).
    If someone could assist me here I would appreciate it. I believe I need to do some type of INNER JOIN but have no idea where the SQL type info lives or the proper structure to use. Thanks
    OperationsManager

    Here's the updated Query for OpsMan 2012 R2:
    To find all members of a given group (change the group name below):
    select SourceObjectDisplayName as 'Group Name', TargetObjectDisplayName as 'Group Members' 
    from RelationshipGenericView 
    where isDeleted=0 
    AND SourceObjectDisplayName = 'Agent Managed Computer
    Group' 
    ORDER BY TargetObjectDisplayName

  • Need help with SQL Query with Inline View + Group by

    Hello Gurus,
    I would really appreciate your time and effort regarding this query. I have the following data set.
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
    1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
    Please Ignore '----', added it for clarity
    I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
    The query should return the following data set
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
    The following is my query. I am kind of lost.
    select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    from (
    select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
    from INVOICE
    group by sequence_id,check_date, check_number, invoice_number, vendor_number
    ) A, INVOICE B
    where A.sequence_id = B.sequence_id
    Thanks,
    Nick

    It looks like it is a duplicate thread - correct me if i'm wrong in this case ->
    Need help with SQL Query with Inline View + Group by
    Regards.
    Satyaki De.

  • SQL Query of an OWB map (row based)

    If I trace a session, execute an OWB map (row based), will the trace file contain the actual SQL query ?
    The problem with me is that when I am executing this row -based OWB map, it is throwing me an error CursorFetchMapTerminationRTV20007 BUT ( plus taking a long time) when I am taking out the intermediate SQL insert query,it is working fine ( and also within a very short period of time)
    Execution status = COMPLETE
    message text = ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    message text = CursorFetchMapTerminationRTV20007
    No. task errors = 0
    No. task warnings = 2
    No. errors = 1
    Since this OWB map (Truncate Insert)  is row based hence I cannot cannot get the back end query from the OWB generated pl/sql package so wondering if I trace the session, check the trace file, may be I will able to see the exact SQL query generated. But wanted to confirm the same.

    Yes, the actual SQL run in the session will be in the trace file.

  • Urgent= How to Group selected columns in sql query

    Hi,
    I need some urgent help on the following sql query. I 'm sure there is an easy way to do this but I'm stacked!Any help will be much appreciated!!
    I have a query to retrieve the following columns:
    I want the first 9 columns to be grouped together (not to be repeated) for any occurence of the last 3 columns (abs.ABSENCE_START_DATE,abs.ABSENCE_END_DATE, abs.DAYS_TAKEN DAYS_TAKEN_analysis)
    SELECT DISTINCT
    sum.employee_number ,
    sum.EMPLOYEE_NAME,
    sum.EMAIL_ADDRESS,
    sum.ORGANIZATION ,
    sum.BCEBF ,
    sum.ALDE ,
    sum.CURYRREMDAYS ,
    sum.DAYS_TAKEN ,
    sum.REMBCE ,
    abs.ABSENCE_START_DATE
    abs.ABSENCE_END_DATE,
    abs.DAYS_TAKEN DAYS_TAKEN_analysis
    --TO_CHAR(TO_CHAR(abs.ABSENCE_START_DATE)||' '||TO_CHAR(abs.ABSENCE_END_DATE)||' '||TO_CHAR(abs.DAYS_TAKEN)) DAYS_TAKEN_ANAL
    FROM
    HB_V_ANNUAL_LEAVE_SUMMARY_REP SUM,
    HB_V_AN_LEAV_DAYS_TAKEN_REP ABS
    WHERE
    sum.employee_number = abs.EMPLOYEE_NUMBER
    ORDER BY
    sum.employee_number ,
    sum.EMPLOYEE_NAME,
    sum.EMAIL_ADDRESS,
    sum.ORGANIZATION ,
    sum.BCEBF ,
    sum.ALDE ,
    sum.CURYRREMDAYS ,
    sum.DAYS_TAKEN ,
    sum.REMBCE
    Any feedback/help on how to do this will be highly appreciated.
    Thanks a lot
    Elena

    Please help!!
    I used the break command to group columns that I do not want to repeat in my query output. When I run the query without formatting is working. But when I put all formatting to produce the required output I dont get the result I want.
    Below is the exact sql query I use:
    <<
    SET TERMOUT OFF
    SET ECHO OFF
    SET ARRAY 35
    SET HEA OFF
    SET FEEDBACK OFF
    SET PAGES 2000
    col beginLINE format A100
    col winsecidLINE format A100
    col placeLINE format A100
    COL LINEempty1 format A100
    COL LINEempty2 format A100
    COL LINEempty3 format A100
    COL LINEempty4 format A100
    COL LINEempty5 format A100
    COL LINEempty6 format A100
    COL LINEempty7 format A100
    COL LINEempty8 format A100
    COL LINEempty9 format A100
    COL LINEempty10 format A100
    col LINECOLempty format A100
    col receiverLINE FORMAT A100
    COL EMP_EMAIL_ADDRESS FORMAT A100
    COL LINEHEADER FORMAT A100
    COL unitsLINE FORMAT A100
    COL lmLINE FORMAT A100
    COL INTITLE FORMAT A100
    COL LINECOL1 FORMAT A100
    COL CIF FORMAT A100
    COL EMPLOYEE_NAME FORMAT A100
    COL ORGANIZATION FORMAT A100
    COL LINECOL2 FORMAT A100
    COL ALHEADER FORMAT A100
    col LINECOL3 FORMAT A100
    col BCEBF FORMAT A100
    col ALDE FORMAT A100
    COL CURYRREMDAYS FORMAT A100
    COL DAYS_TAKEN FORMAT A100
    col LINECOL4 FORMAT A100
    COL REMBCE FORMAT A100
    col LINECOL5 FORMAT A100
    col LINECOL6 FORMAT A100
    col ALHEADER2 FORMAT A100
    col LINECOL7 FORMAT A100
    col endLINE FORMAT A100
    break on beginLINE on winsecidLINE on placeLINE on LINEempty1 ON LINEempty2 ON LINEempty3 ON LINEempty4 ON LINEempty5 ON LINEempty6 ON LINEempty7 ON LINEempty8 ON LINEempty9 ON LINEempty10 on receiverLINE on EMP_EMAIL_ADDRESS on LINEHEADER on unitsLINE on lmLINE on INTITLE on LINECOL1 on CIF on EMPLOYEE_NAME on ORGANIZATION on LINECOL2 on ALHEADER on LINECOL3 on BCEBF on ALDE on CURYRREMDAYS on DAYS_TAKEN on LINECOL4 on REMBCE on LINECOL5 on LINECOL6 on ALHEADER2 on LINECOL7 ON LINEempty11 ON endREPORT on endLINE
    SPOOL C:\FORMATout.txt
    SELECT
    '{{begin}} '||chr(10) beginLINE,
    '{{winsecid 999999}} '||chr(10) winsecidLINE,
    '{{place rbsemail.tif 0 0}} '||chr(10) placeLINE,
    ' '||chr(10) LINEempty1,
    ' '||chr(10) LINEempty2,
    ' '||chr(10) LINEempty3,
    ' '||chr(10) LINEempty4,
    ' '||chr(10) LINEempty5,
    ' '||chr(10) LINEempty6,
    ' '||chr(10) LINEempty7,
    ' '||chr(10) LINEempty8,
    ' '||chr(10) LINEempty9,
    ' '||chr(10) LINEempty10,
    '{{from [email protected]}} '||chr(10) receiverLINE,
    '{{fax '|| EMAIL_ADDRESS||' }} '||chr(10) EMP_EMAIL_ADDRESS,
    '{{Subject Annual Leave Summary Report as at '||sysdate||' }} '||chr(10) LINEHEADER,
    '{{units cm}} '||chr(10) unitsLINE,
    '{{lm 2.0}} '||chr(10) lmLINE,
    'ANNUAL LEAVE SUMMARY REPORT AS AT '||sysdate INTITLE,
    '---------------------------------------------------------------------' LINECOL1,
    'CIF: '||CIF CIF,
    'EMPLOYEE NAME: '||EMPLOYEE_NAME EMPLOYEE_NAME,
    'DEPARTMENT DETAILS: '||ORGANIZATION ORGANIZATION,
    '---------------------------------------------------------------------' LINECOL2,
    'ANNUAL LEAVE DETAILS:' ALHEADER,
    '---------------------------------------------------------------------' LINECOL3,
    'BALANCE B/F FROM PREVIOUS YEAR: '||BCEBF BCEBF,
    'DAYS ENTITLED FOR THE CURRENT YEAR: '||ALDE ALDE,
    'CURRENT YEAR REMAINING DAYS: '||CURYRREMDAYS CURYRREMDAYS,
    'DAYS TAKEN FOR THE CURRENT YEAR: '||DAYS_TAKEN DAYS_TAKEN,
    '---------------------------------------------------------------------' LINECOL4,
    'REMAINING BALANCE: '||REMBCE REMBCE,
    '---------------------------------------------------------------------' LINECOL5,
    '---------------------------------------------------------------------' LINECOL6,
    'ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:' ALHEADER2,
    '---------------------------------------------------------------------' LINECOL7,
    TO_CHAR('START DATE: '||ABSENCE_START_DATE||' '||'END DATE: '||ABSENCE_END_DATE||' '||'DAYS TAKEN : '||DAYS_TAKEN_ANAL) AL_DAYS_ANAL,
    ' '||chr(10) LINEempty11,
    '-- End of Report -- '||chr(10) endREPORT,
    '{{end}} '||chr(10) endLINE
    FROM HB_V_AN_LEAV_SUM_DAYSTAKEN_REP
    WHERE CIF IN ('098033','098024')
    ORDER BY
    beginLINE ,
    winsecidLINE,
    placeLINE ,
    LINEempty1,
    LINEempty2,
    LINEempty3,
    LINEempty4,
    LINEempty5,
    LINEempty6,
    LINEempty7,
    LINEempty8,
    LINEempty9,
    LINEempty10,
    receiverLINE,
    EMP_EMAIL_ADDRESS,
    LINEHEADER ,
    unitsLINE ,
    lmLINE ,
    INTITLE ,
    LINECOL1,
    CIF ,
    EMPLOYEE_NAME ,
    ORGANIZATION ,
    LINECOL2 ,
    ALHEADER ,
    LINECOL3,
    BCEBF ,
    ALDE ,
    CURYRREMDAYS ,
    DAYS_TAKEN ,
    LINECOL4 ,
    REMBCE ,
    LINECOL5 ,
    LINECOL6 ,
    ALHEADER2 ,
    LINECOL7 ,
    LINEempty11,
    endREPORT,
    endLINE
    spool off
    >>
    The required output I want to get is:
    <<
    {{begin}}
    {{winsecid 750612}}
    {{place rbsemail.tif 0 0}}
    {{from [email protected]}}
    {{fax [email protected] }}
    {{Subject Annual Leave Summary Report as at 04-APR-08 }}
    {{units cm}}
    {{lm 2.0}}
    ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
    CIF: 098024
    EMPLOYEE NAME: Christou Christos Panteli
    DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
    ANNUAL LEAVE DETAILS:
    BALANCE B/F FROM PREVIOUS YEAR: 9
    DAYS ENTITLED FOR THE CURRENT YEAR: 27
    CURRENT YEAR REMAINING DAYS: 24
    DAYS TAKEN FOR THE CURRENT YEAR: -3
    REMAINING BALANCE: 33
    ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
    START DATE: 04-JAN-08 END DATE: 04-JAN-08 DAYS TAKEN : 1
    START DATE: 24-JAN-08 END DATE: 24-JAN-08 DAYS TAKEN : 1
    START DATE: 20-FEB-08 END DATE: 20-FEB-08 DAYS TAKEN : 1
    -- End of Report --
    {{end}}
    {{begin}}
    {{winsecid 750612}}
    {{place rbsemail.tif 0 0}}
    {{from [email protected]}}
    {{fax [email protected]}}
    {{Subject Annual Leave Summary Report as at 04-APR-08 }}
    {{units cm}}
    {{lm 2.0}}
    ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
    CIF: 098033
    EMPLOYEE NAME: Demetriou Elena Steliou
    DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
    ANNUAL LEAVE DETAILS:
    BALANCE B/F FROM PREVIOUS YEAR: 15
    DAYS ENTITLED FOR THE CURRENT YEAR: 27
    CURRENT YEAR REMAINING DAYS: 25
    DAYS TAKEN FOR THE CURRENT YEAR: -2
    REMAINING BALANCE: 40
    ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
    START DATE: 15-JAN-08 END DATE: 15-JAN-08 DAYS TAKEN : 1
    START DATE: 24-MAR-08 END DATE: 24-MAR-08 DAYS TAKEN : 1
    -- End of Report --
    {{end}}
    >>
    However the actual output we get from the above query is as follows:
    <<
    {{begin}}
    {{winsecid 750612}}
    {{place rbsemail.tif 0 0}}
    {{from [email protected]}}
    {{fax [email protected] }}
    {{Subject Annual Leave Summary Report as at 04-APR-08 }}
    {{units cm}}
    {{lm 2.0}}
    ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
    CIF: 098024
    EMPLOYEE NAME: Christou Christos Panteli
    DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
    ANNUAL LEAVE DETAILS:
    BALANCE B/F FROM PREVIOUS YEAR: 9
    DAYS ENTITLED FOR THE CURRENT YEAR: 27
    CURRENT YEAR REMAINING DAYS: 24
    DAYS TAKEN FOR THE CURRENT YEAR: -3
    REMAINING BALANCE: 33
    ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
    START DATE: 04-JAN-08 END DATE: 04-JAN-08 DAYS TAKEN : 1
    -- End of Report --
    {{end}}
    START DATE: 24-JAN-08 END DATE: 24-JAN-08 DAYS TAKEN : 1
    START DATE: 20-FEB-08 END DATE: 20-FEB-08 DAYS TAKEN : 1
    {{fax [email protected] }}
    {{Subject Annual Leave Summary Report as at 04-APR-08 }}
    {{units cm}}
    {{lm 2.0}}
    ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
    CIF: 098033
    EMPLOYEE NAME: Demetriou Elena Steliou
    DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
    ANNUAL LEAVE DETAILS:
    BALANCE B/F FROM PREVIOUS YEAR: 15
    DAYS ENTITLED FOR THE CURRENT YEAR: 27
    CURRENT YEAR REMAINING DAYS: 25
    DAYS TAKEN FOR THE CURRENT YEAR: -2
    REMAINING BALANCE: 40
    ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
    START DATE: 15-JAN-08 END DATE: 15-JAN-08 DAYS TAKEN : 1
    -- End of Report --
    {{end}}
    START DATE: 24-MAR-08 END DATE: 24-MAR-08 DAYS TAKEN : 1
    >>
    IF ANYONE CAN HELP ON THIS I WOULD REALLY APPRECIATE IT!
    THANKS A LOT!
    Best regards,
    Elena

Maybe you are looking for

  • Does Final Cut Pro X support all video files as did its prior version Final Cut Pro Studio?

    Hi, Use to have a Mac Pro and had Fina Cut Pro Studio. Now I have just got a new Macbook Pro (Lion), and have just purchased the new Final Cut Pro X from the App store. I am having problems importing 3gps files into FCP X. I never had a problem with

  • HttpException (0x80004005): Request timed out at Windows Server 2012

    Dear All, I am using "Microsoft Interop Word dll for resume parsing. My functionality is working fine at my local machine. I have two server one is Windows 2008 and Windows 2012 server. I have deployed my code on both server. In Windows 2008 is worki

  • "user not found"; can't synchronize xmarks

    I want to sync my bookmarks to a new laptop. Problem: I have tried both of my email addresses but neither works ("user not found"). I think I have the correct password. What to do? I never had a Master Password, but apparently resetting that or start

  • Import Function problem Lightroom 5

    I'm testing Lightroom 5 and it seems to be great, but the import function seems to be stupid! Even when I make a new folder in lightroom it doesn't import there, it makes a new folder in Lightroom using where the photos used to be! I've lost some now

  • Another pointless whinge?

    Right, new here so not really sure what I'm trying to achieve; I suspect that, like many here, I've just become so desparate that I'm hoping writing it down may be cathartic. My issue began in March 2012 when I asked BT to install a phone line to my