Need help in GROUPING of COLUMN Based Query

Hi,
I am facing problem in generating a scenario:
I have built a Query like this:
SELECT
a.sal,
a.country
FROM
employee a,
department d
WHERE
a.dept_code=b.dept_code
I want the query where the Query will produce a result set based on SALARY based on COUNTRY.
For example if the COUNTRY is US then it will show the breaking of SALARIES.If the COUNTRY is NON US it will club the SALRIES
Any help will be needful for me

Hi,
Here's one way:
SELECT       deptno
,       SUM (sal)     AS sal
FROM       scott.emp
GROUP BY  deptno
,            CASE
           WHEN  deptno = 30
           THEN  empno
       END
ORDER BY  deptno
;Output:
`   DEPTNO        SAL
        10       8750
        20      10875
        30       1600
        30       1250
        30       1250
        30       2850
        30       1500
        30        950In the table, there are 3 rows with deptno=10, and 5 rows with deptno=20, but the CASE expression returns NULL for all of them, so there is only 1 sub-group for each of those deptnos.
Edited by: Frank Kulash on Mar 13, 2013 5:41 AM
This is essentially the same solution that Jeneesh already posted. (Sorry, I didn't see that before.)

Similar Messages

  • Need help in SQL , Subtract column based on the condition in the Row

    Hi all ,
    I’m new to Sql Queries; I have a requirement which involves Sql query,
    Can anyone tell the How to proceed or provide me Sql
    Here goes the requirement
    Current Table
    ID |-|Month|-|Data
    1|-|Jan-10|-|10.00
    2|-|Feb-10|-|20.00
    3|-|Mar-10|-|30.00
    4|-|Apr-10|-|50.00
    5|-|May-10|-|60.00
    6|-|Jun-10|-|70.00
    7|-|Jul-10|-|100.00
    8|-|Aug-10|-|110.00
    9|-|Sep-10|-|120.00
    10|-|Oct-10|-|140.00
    11|-|Nov-10|-|150.00
    12|-|Dec-10|-|170.00
    13|-|Jan-09|-|180.67
    14|-|Feb-09|-|194.67
    15|-|Mar-09|-|208.67
    16|-|Apr-09|-|222.67
    Format needed
    ID |-|Month|-|Data|-|Base on this condition
    1|-|Jan-10|-|10.00|-|Jan 10
    2|-|Feb-10|-|10.00|-|Feb10-Jan10
    3|-|Mar-10|-|10.00|-|Mar10 - Feb10
    4|-|Apr-10|-|20.00|-|Apr10 - Mar10
    5|-|May-10|-|10.00|-|May10 - Apr10
    6|-|Jun-10|-|10.00|-|Jun10 - May10
    7|-|Jul-10|-|30.00|-|Jul10 - Aug10
    8|-|Aug-10|-|10.00|-|Aug10 - Jul10
    9|-|Sep-10|-|10.00|-|Sep10 -Aug10
    10|-|Oct-10|-|20.00|-|Oct10 -Sep10
    11|-|Nov-10|-|10.00|-|Nov10 - Oct10
    12|-|Dec-10|-|20.00|-|Dec10 - Nov10
    13|-|Jan-09|-|10.67|-|Jan 09
    14|-|Feb-09|-|14.00|-|Feb09-Jan09
    15|-|Mar-09|-|14.00|-|Mar09 - Feb09
    16|-|Apr-09|-|14.00|-|Apr09 - Mar09
    Thanks in advance
    Astle

    Welcome to the forum!
    this?
    select id
         , mon
         , data
         , data - lag (data, 1, 0) over (partition by trunc (mon, 'yyyy')
                   order by mon)
      from test
    order by idas in
    SQL> with test as
      2  (
      3  select 1 id ,to_date ('Jan-10', 'Mon-rr') mon,10.00 data from dual union all
      4  select 2,to_date ('Feb-10', 'Mon-rr'),20.00 data from dual union all
      5  select 3,to_date ('Mar-10', 'Mon-rr'),30.00 data from dual union all
      6  select 4,to_date ('Apr-10', 'Mon-rr'),50.00 data from dual union all
      7  select 5,to_date ('May-10', 'Mon-rr'),60.00 data from dual union all
      8  select 6,to_date ('Jun-10', 'Mon-rr'),70.00 data from dual union all
      9  select 7,to_date ('Jul-10', 'Mon-rr'),100.00 data from dual union all
    10  select 8,to_date ('Aug-10', 'Mon-rr'),110.00 data from dual union all
    11  select 9,to_date ('Sep-10', 'Mon-rr'),120.00 data from dual union all
    12  select 10,to_date ('Oct-10', 'Mon-rr'),140.00 data from dual union all
    13  select 11,to_date ('Nov-10', 'Mon-rr'),150.00 data from dual union all
    14  select 12,to_date ('Dec-10', 'Mon-rr'),170.00 data from dual union all
    15  select 13,to_date ('Jan-09', 'Mon-rr'),180.67 data from dual union all
    16  select 14,to_date ('Feb-09', 'Mon-rr'),194.67 data from dual union all
    17  select 15,to_date ('Mar-09', 'Mon-rr'),208.67 data from dual union all
    18  select 16,to_date ('Apr-09', 'Mon-rr'),222.67 data from dual
    19  )
    20  select id
    21       , mon
    22       , data
    23       , data - lag (data, 1, 0) over (partition by trunc (mon, 'yyyy')
    24                 order by mon)
    25    from test
    26   order by id
    27  ;
            ID MON               DATA DATA-LAG(DATA,1,0)OVER(PARTITI
             1 1-1-2010            10                             10
             2 1-2-2010            20                             10
             3 1-3-2010            30                             10
             4 1-4-2010            50                             20
             5 1-5-2010            60                             10
             6 1-6-2010            70                             10
             7 1-7-2010           100                             30
             8 1-8-2010           110                             10
             9 1-9-2010           120                             10
            10 1-10-2010          140                             20
            11 1-11-2010          150                             10
            12 1-12-2010          170                             20
            13 1-1-2009        180,67                         180,67
            14 1-2-2009        194,67                             14
            15 1-3-2009        208,67                             14
            16 1-4-2009        222,67                             14
    16 rows selected

  • Need help in group left report

    i need help in group left report
    i am making group left report in which all group data on top is repeating as many time as detail record is .
    for axampel
    if
    group record:
    fielda fieldb field c
    fielda fieldb field c
    fielda fieldb field c
    fielda fieldb field c
    detail record :
    fieldd fielde feildf
    fieldd fielde feild
    fieldd fielde feild
    fieldd fielde feildf
    how i can show group record on top once and on each group record show detail record belong to master record.
    plz help me
    A.R

    I think you Should go for Group above report...
    and if you want group left only and also want to display master once then
    put all master fields above but yeah take care of it's master repeting frame
    it should not change...
    and if you want i can send you an example...
    Enjoy Oracle...

  • NEED HELP IN REDUCING THE LENGTH OF QUERY WHICH IS ATTACHED IN A FILE PL_SQ

    Hi Everyone,
    THANKS FOR POSTING THE REPLIES FOR MY LAST THREAD. THAT REALLY HELPED. I CAME BACK AGAIN BECAUSE I NEED HELP FROM THIS FORUM IN REDUING THE LENGTH OF MY QUERY WHICH I HAD GIVEN BELOW. i DIDN'T HAD THE CHOICE OF ATTACHING A FILE OF MY DATA HERE.ITS VERY HUGE DATA SO I AM NOT ABLE TO PROVIDE ATLEAST SAMPLE DATA BECAUSE THE COLUMNS ARE OVERLAPPING IF I AM PASTING THE DATA HERE. I HOPE IT WILL BE UNDERSTANDABLE. THE QUERY WHICH I WROTE IS TOO LONG AND TAKING HOURS TOGETHER TO RUN AND DISPLAY RESULT. IT WOULD BE A GREAT FAVOUR TO ME IF ANYONE CAN REDUCE THE LINES IN MY QUERY AND MAKE IT RUN FAST....PLEASE I WAS NOT KNOWING THE WAY HOW TO MAKE IT SHORT. IT HAS MANY LOGICS IN IT... :? PLEASE SUGGEST ME IF THERE IS ANY OPTION FOR ATTACHING A FILE SO THAT I CAN SEND MY SAMPLE DATA...
    select pt.product code,
    pt.product status,
    pt.store code,
    pt.store status,
    pr.scheduled date,
    pr.actual date,
    pl.scheduled date,
    pl.actual date,
    ps.scheduled date,
    ps.actual date,
    fo.scheduled date,
    fo.actual date,
    fb.scheduled date,
    fb.actual date,
    fod.scheduled date,
    fod.actual date,
    lo.scheduled date,
    lo.actual date,
    lom.scheduled date,
    lom.actual date,
    lod.scheduled date,
    lod.actual date,
    /*pr*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(pr.scheduled date,
    cast(pr.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Planned' THEN
    NVL2(pr.scheduled date,
    cast(pr.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_pr_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(pr.actual date,
    cast(pr.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    pr.scheduled date is null THEN
    NVL2(pr.actual date,
    cast(pr.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    pr.scheduled date < CURRENT_DATE THEN
    NVL2(pr.actual date,
    cast(pr.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    pr.scheduled date >= CURRENT_DATE THEN
    NVL2(pr.actual date,
    cast(pr.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'Planned' and
    pr.scheduled date is null THEN
    NVL2(pr.actual date,
    cast(pr.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'Planned' and
    pr.scheduled date < CURRENT_DATE THEN
    NVL2(pr.actual date,
    cast(pr.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Planned' and
    pr.scheduled date >= CURRENT_DATE THEN
    NVL2(pr.actual date,
    cast(pr.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_pr_ACT,
    /*pl*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(pl.scheduled date,
    cast(pl.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Planned' THEN
    NVL2(pl.scheduled date,
    cast(pl.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_pl_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(pl.actual date,
    cast(pl.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    pl.scheduled date is null THEN
    NVL2(pl.actual date,
    cast(pl.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    pl.scheduled date < CURRENT_DATE THEN
    NVL2(pl.actual date,
    cast(pl.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    pl.scheduled date >= CURRENT_DATE THEN
    NVL2(pl.actual date,
    cast(pl.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'Planned' and
    pl.scheduled date is null THEN
    NVL2(pl.actual date,
    cast(pl.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'Planned' and
    pl.scheduled date < CURRENT_DATE THEN
    NVL2(pl.actual date,
    cast(pl.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Planned' and
    pl.scheduled date >= CURRENT_DATE THEN
    NVL2(pl.actual date,
    cast(pl.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_pl_ACT,
    /*ps*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(ps.scheduled date,
    cast(ps.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' THEN
    NVL2(ps.scheduled date,
    cast(ps.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_ps_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(ps.actual date,
    cast(ps.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    ps.scheduled date is null THEN
    NVL2(ps.actual date,
    cast(ps.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    ps.scheduled date < CURRENT_DATE THEN
    NVL2(ps.actual date,
    cast(ps.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    ps.scheduled date >= CURRENT_DATE THEN
    NVL2(ps.actual date,
    cast(ps.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    ps.scheduled date is null THEN
    NVL2(ps.actual date,
    cast(ps.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    ps.scheduled date < CURRENT_DATE THEN
    NVL2(ps.actual date,
    cast(ps.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' and
    ps.scheduled date >= CURRENT_DATE THEN
    NVL2(ps.actual date,
    cast(ps.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_ps_ACT,
    /*fo*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(fo.scheduled date,
    cast(fo.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' THEN
    NVL2(fo.scheduled date,
    cast(fo.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_fo_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(fo.actual date,
    cast(fo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fo.scheduled date is null THEN
    NVL2(fo.actual date,
    cast(fo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fo.scheduled date < CURRENT_DATE THEN
    NVL2(fo.actual date,
    cast(fo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fo.scheduled date >= CURRENT_DATE THEN
    NVL2(fo.actual date,
    cast(fo.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    fo.scheduled date is null THEN
    NVL2(fo.actual date,
    cast(fo.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    fo.scheduled date < CURRENT_DATE THEN
    NVL2(fo.actual date,
    cast(fo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' and
    fo.scheduled date >= CURRENT_DATE THEN
    NVL2(fo.actual date,
    cast(fo.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_fo_ACT,
    /*fb*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(fb.scheduled date,
    cast(fb.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' THEN
    NVL2(fb.scheduled date,
    cast(fb.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_fb_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(fb.actual date,
    cast(fb.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fb.scheduled date is null THEN
    NVL2(fb.actual date,
    cast(fb.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fb.scheduled date < CURRENT_DATE THEN
    NVL2(fb.actual date,
    cast(fb.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fb.scheduled date >= CURRENT_DATE THEN
    NVL2(fb.actual date,
    cast(fb.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    fb.scheduled date is null THEN
    NVL2(fb.actual date,
    cast(fb.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    fb.scheduled date < CURRENT_DATE THEN
    NVL2(fb.actual date,
    cast(fb.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' and
    fb.scheduled date >= CURRENT_DATE THEN
    NVL2(fb.actual date,
    cast(fb.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_fb_ACT,
    /*fod*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Compldeted' OR
    pt.store status = 'Active' THEN
    NVL2(fod.scheduled date,
    cast(fod.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'pldanned' THEN
    NVL2(fod.scheduled date,
    cast(fod.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_fod_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(fod.actual date,
    cast(fod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fod.scheduled date is null THEN
    NVL2(fod.actual date,
    cast(fod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fod.scheduled date < CURRENT_DATE THEN
    NVL2(fod.actual date,
    cast(fod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fod.scheduled date >= CURRENT_DATE THEN
    NVL2(fod.actual date,
    cast(fod.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    fod.scheduled date is null THEN
    NVL2(fod.actual date,
    cast(fod.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    fod.scheduled date < CURRENT_DATE THEN
    NVL2(fod.actual date,
    cast(fod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' and
    fod.scheduled date >= CURRENT_DATE THEN
    NVL2(fod.actual date,
    cast(fod.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_fod_ACT,
    /*lo*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(lo.scheduled date,
    cast(lo.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' THEN
    NVL2(lo.scheduled date,
    cast(lo.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_lo_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(lo.actual date,
    cast(lo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lo.scheduled date is null THEN
    NVL2(lo.actual date,
    cast(lo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lo.scheduled date < CURRENT_DATE THEN
    NVL2(lo.actual date,
    cast(lo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lo.scheduled date >= CURRENT_DATE THEN
    NVL2(lo.actual date,
    cast(lo.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    lo.scheduled date is null THEN
    NVL2(lo.actual date,
    cast(lo.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    lo.scheduled date < CURRENT_DATE THEN
    NVL2(lo.actual date,
    cast(lo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' and
    lo.scheduled date >= CURRENT_DATE THEN
    NVL2(lo.actual date,
    cast(lo.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_lo_ACT,
    /*lom*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(lom.scheduled date,
    cast(lom.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' THEN
    NVL2(lom.scheduled date,
    cast(lom.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_lom_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(lom.actual date,
    cast(lom.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lom.scheduled date is null THEN
    NVL2(lom.actual date,
    cast(lom.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lom.scheduled date < CURRENT_DATE THEN
    NVL2(lom.actual date,
    cast(lom.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lom.scheduled date >= CURRENT_DATE THEN
    NVL2(lom.actual date,
    cast(lom.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    lom.scheduled date is null THEN
    NVL2(lom.actual date,
    cast(lom.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    lom.scheduled date < CURRENT_DATE THEN
    NVL2(lom.actual date,
    cast(lom.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' and
    lom.scheduled date >= CURRENT_DATE THEN
    NVL2(lom.actual date,
    cast(lom.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_lom_ACT,
    /*lod*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(lod.scheduled date,
    cast(lod.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' THEN
    NVL2(lod.scheduled date,
    cast(lod.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_lod_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(lod.actual date,
    cast(lod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lod.scheduled date is null THEN
    NVL2(lod.actual date,
    cast(lod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lod.scheduled date < CURRENT_DATE THEN
    NVL2(lod.actual date,
    cast(lod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lod.scheduled date >= CURRENT_DATE THEN
    NVL2(lod.actual date,
    cast(lod.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    lod.scheduled date is null THEN
    NVL2(lod.actual date,
    cast(lod.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    lod.scheduled date < CURRENT_DATE THEN
    NVL2(lod.actual date,
    cast(lod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' and
    lod.scheduled date >= CURRENT_DATE THEN
    NVL2(lod.actual date,
    cast(lod.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_lod_ACT
    from
    product table pt,
    event table pr,
    event table pl,
    event table ps,
    event table fo,
    event table fb,
    event table fod,
    event table lo,
    event table lom,
    event table lod
    where
    pt.product code = pr.product code
    and pt.store code = pr.store code
    and pt.product code = pl.product code
    and pt.store code = pl.store code
    and pt.product code = fo.product code
    and pt.store code = fo.store code
    and pt.product code = fb.product code
    and pt.store code = fb.store code
    and pt.product code = fod.product code
    and pt.store code = fod.store code
    and pt.product code = lo.product code
    and pt.store code = lo.store code
    and pt.product code = lom.product code
    and pt.store code = lom.store code
    and pt.product code = lod.product code
    and pt.store code = lod.store code
    and pr.product code=pl.product code
    and pl.store code=ps.store code
    and ps.product code=fo.product code
    and fo.store code=fb.store code
    and fb.product code=fod.product code
    and fod.store code=lo.store code
    and lo.product code=lom.product code
    and lom.store code=lod.store code
    and pr.event code=1001
    and pl.event code=1002
    and ps.event code=1003
    and fo.event code=1004
    and fb.event code=1005
    and fod.event code=1006
    and lo.event code=1007
    and lom.event code=1008
    and lod.event code=1009
    order by product code,store code;
    THANKS IN ADVANCE FOR SPARING YOUR TIME IN UNDERSTANDING MY PROVLEM....
    REGARDS,
    MYTHRI.

    986300 wrote:
    from
    product table pt,
    event table pr,
    event table pl,
    event table ps,
    event table fo,
    event table fb,
    event table fod,
    event table lo,
    event table lom,
    event table lodabove is NOT valid SQL syntax

  • Need help in writing NVARCHAR2 column to an excel sheet

    Hi All,
    I have a NVARCHAR2 column in my table. I want to store the data present in the column into an excel file. When i write the data to an excel file the data is getting converted to some other form. It's not in human readable form.
    Language is not fixed for the column.
    I need help in storing the NVARCHAR2 data into an excel file without any implicit conversion done by the oracle.
    Please help.
    Thanks,
    Girish G
    Edited by: Girish G on Jul 14, 2011 2:02 AM

    Export data to BLOB (csv)

  • Need help on getting the column names of Tabletype

    I have a table Mapping with the following values: This Mapping table contains the table names (in Tabname) and the column names(colname) of various tables and values(ValuesTobeFilled) for the columns.
    I have to insert into the tables present in the Tabname field with the values present in the ValuesTobeFilled in the columns present in the Colname field.
    Note: The Mapping table need not contain all the columns of the base table. The columns that are not present can be filled with null. And this mapping table is not fixed i.e. rows can be inserted/deleted frequently.
    Sample values in mapping table:
    Tabname                        Colname        ValuesTobeFilled
    sample_items     Eno     Corresponding Expression to get the values from XML input
    sample_items     Ename     Corresponding Expression to get the values from XML input
    XXX     YYY     Corresponding Expression to get the values from XML input
    Before filling in the actual tables, I have to store the entire data temporarily and I have used a tabletype declared as follows:
    TYPE T_sample_items IS TABLE OF sample_items%ROWTYPE INDEX BY BINARY_INTEGER;
    l_sample_items T_sample_items;
    Where the table sample_items have the following columns:
    •     Eno
    •     Ename
    •     Eaddress
    •     Eemail
    So, the tabletype should be filled as:
    Eno     Ename     Eaddress     EEmail
    1     XXX     -     -
    I have declared a cursor to select the values from mapping table and I need to fill in the ValuesTobeFilled values to the corresponding table.
    CURSOR c_xpath (c_tname mapping.TABNAME%type)
    IS
    select * from mapping where tabname = c_tname;
    CURSOR c_tables
    IS
    SELECT DISTINCT TABNAME FROM mapping;
    FOR crsr IN c_tables
    LOOP
    p_tname := CRSR.TABNAME;
    FOR csr IN c_xpath(p_tname)
    LOOP
    IF l_xml_doc.EXISTSNODE(CSR.XPATH_EXP) = 1
    THEN
    l_node_value := l_xml_doc.extract(CSR.XPATH_EXP).getStringVal(); -- This is the value to be stored in the corresponding column
    ELSE
         l_node_value := NULL;
    END IF;
    IF CSR.COLUMN_NAME = ‘eno’
    THEN
         l_sample_items(1).eno := l_node_value;
    ELSIF CSR.COLUMN_NAME = ‘ename’
    THEN
         l_sample_items(1).name := l_node_value;
    END IF;
    END LOOP;
    END LOOP;      
    And I need to eliminate hard coding while comparing the column names (in the following piece of code) as the Mapping table values are subject to insertion/deletion:
    IF CSR.COLUMN_NAME = ‘eno’
    THEN
         l_sample_items(1).eno := l_node_value;
    ELSIF CSR.COLUMN_NAME = ‘ename’
    THEN
         l_sample_items(1).ename := l_node_value;
    END IF;
    I need to insert the values directly into the tabletype without this hardcoding. Please suggest me ways to compare the mapping table values with the field (column) names of the tabletype. If it is not possible using tabletype, please suggest any other ways of fixing the problem.
    Many thanks,
    Gopi

    I take it this isn't going to be a serious production system at the end of the day?
    Storing metadata in tables for extraction and insertion of data is just wrong in so many ways. It smells heavily of Entity Attribute Value modelling, which is the most wrong way to use a relational database and is known to have major performance implications and be liable to bugs and issues. The idea that EAV modelling allows for 'generic' databases where new data items can be added flexibly later on without having to change code is usually justified with an excuse of "it means we don't have to update all our tables when we want a new column" which is easily countered with "if you're adding a single column a good relational design wouldn't require you to add it to more than one table anyway in most cases".
    Just what exactly are you trying to do and why? There has to be a better way.

  • Need help in Group by query

    Hi All,
    I am using Oracle 11 g.
    I have a query which is giving output as
    SELECT o.campgn_no , m.lang , COUNT(1)
    FROM tg_main m, sp_offer o
    WHERE m.offer_id = o.offer_id AND o.campgn_no IN (SELECT campgn_no FROM sp_campgn_cntrl WHERE product_code = 'ONB')
    GROUP BY o.campgn_no, m.lang;
    Campgn Lang Count
    CNB26 F 4
    ONB26 E 1065
    CNB26 E 316
    ONB26 F 96
    But i need output as
    Campgn     E     F
    ONB26     1065     96
    CNB26     316     4
    Let me know how to do this.
    Thanks in Advance.
    Thanks,
    lony

    Maybe (seems I'd better leave the Forum for a while)
    select campgn_no,
           max(e) e,
           max(f) f
      from (SELECT o.campgn_no,
                   sum(case when m.lang = 'E' then 1 end) e,
                   sum(case when m.lang = 'F' then 1 end) f
              FROM tg_main m,
                   sp_offer o
             WHERE m.offer_id = o.offer_id
               AND o.campgn_no IN (SELECT campgn_no
                                     FROM sp_campgn_cntrl
                                    WHERE product_code = 'ONB'
             GROUP BY o.campgn_no,m.lang
    GROUP BY campgn_noRegards
    Etbin

  • Need help on group by query problem.

    Hi,
    I've a table like..
         CREATE TABLE DPT(DEPTNO NUMBER(4),HIREDATE DATE);
         INSERT INTO DPT VALUES(10,SYSDATE);
         INSERT INTO DPT VALUES(10,SYSDATE+1);
         INSERT INTO DPT VALUES(10,SYSDATE+2);
         INSERT INTO DPT VALUES(10,SYSDATE+3);
         INSERT INTO DPT VALUES(10,SYSDATE+4);
         INSERT INTO DPT VALUES(10,SYSDATE+5);
         INSERT INTO DPT VALUES(20,SYSDATE);
         INSERT INTO DPT VALUES(20,SYSDATE+1);
         INSERT INTO DPT VALUES(20,SYSDATE+2);
         INSERT INTO DPT VALUES(20,SYSDATE+3);
         INSERT INTO DPT VALUES(30,SYSDATE);
         INSERT INTO DPT VALUES(30,SYSDATE+1);
         INSERT INTO DPT VALUES(30,SYSDATE+2);
         INSERT INTO DPT VALUES(30,SYSDATE+3);
         INSERT INTO DPT VALUES(30,SYSDATE+4);
    SELECT DEPTNO,HIREDATE FROM DPT;
    DEPTNO     HIREDATE
    10     30-OCT-09
    10     31-OCT-09
    10     1-NOV-09
    10     2-NOV-09     
    10     3-NOV-09
    10     4-NOV-09
    20     30-OCT-09
    20     31-OCT-09
    20     1-NOV-09
    END SO ON..
    Actually DPT table having 11 lacs records and Every deptno has got different hiredates.
    I want to retrieve the deptno with minimum hiredate i.e deptno having first date.
    So i've written a query like this using group by clause , When i use the group by clause
    it is taking almost 15 sec to give the result.
    SELECT DEPTNO,MIN(HIREDATE) FROM DPT GROUP BY DEPTNO;
    DEPTNO     HIREDATE
    10     30-OCT-09
    20     30-OCT-09
    30     30-OCT-09
    So is there any otherway of achieving the above result without using group by hence it is taking much time.
    Am using Oracle 10g, TOAD 8.6.1 version
    I've done the analyzing of the table & there are Indexes on both the columns.
    Explan result Below:
    PLAN_TABLE_OUTPUT
    Plan hash value: 682192801
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 231K| 2938K| | 3804 (4)| 00:00:46 |
    | 1 | SORT GROUP BY | | 231K| 2938K| 32M| 3804 (4)| 00:00:46 |
    | 2 | INDEX FAST FULL SCAN| DPT_NDX1 | 1180K| 14M| | 1019 (1)| 00:00:13 |
    Please give the other ways of writing the same query for improving the performance.
    Regards,
    Arjun.

    Hi Karhick,
    Thanks for the reply. It is giving expected result,but performance not improved.Please find the below Eplan
    PLAN_TABLE_OUTPUT
    Plan hash value: 1880836313
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1180K| 32M| | 6714 (2)| 00:01:21 |
    |* 1 | VIEW | | 1180K| 32M| | 6714 (2)| 00:01:21 |
    |* 2 | WINDOW SORT PUSHED RANK| | 1180K| 14M| 54M| 6714 (2)| 00:01:21 |
    | 3 | INDEX FAST FULL SCAN | DPT_NDX1 | 1180K| 14M| | 1019 (1)| 00:00:13 |
    Predicate Information (identified by operation id):
    1 - filter("RNO"=1)
    2 - filter(ROW_NUMBER() OVER ( PARTITION BY "DEPTNO" ORDER BY "HIREDATE")<=1)
    What i've to do now. Please let me know.
    Regards,
    Arjun.

  • Need help with group by query with condition

    Name
    ID
    A1
    1
    A2
    1
    A3
    1
    A1
    1
    A2
    2
    A2
    3
    A3
    3
    A1
    4
    A2
    4
    A3
    5
    I want to get result of total count  where ID is less than 4
    A1 - 2
    A2 - 3
    A3 -  2

    Hi,
    If you want to get 0 counts for names that don't have any low ids, then use a CASE expression instead of a WHERE clause.
    You didn't post CREATE TABLE and INSERT statements for your sample data, so I'll use scott.emp to illustrate.
    Say you want to see how many sals in each job are under 3000, like this:
    JOB       UNDER_3_CNT
    CLERK               4
    SALESMAN            4
    PRESIDENT           0
    MANAGER             3
    ANALYST             0
    Here's one way to do that:
    SELECT    job
    ,         COUNT (CASE WHEN sal < 3000 THEN 1 END)  AS under_3_cnt
    FROM      scott.emp
    GROUP BY  job
    This shows that there are ANALYSTs and PRESIDENTs in the scott.emp table; there just don't happen to be any with sals under 3000.

  • Need help to extend a EO based VO

    Hi All,
    I have VO which is EO based. All the select columns are displayed in an advance table on a page. Now i need to add another field in the advance table which is in another table.
    This is VO.xml file:
    <?xml version="1.0" encoding='windows-1252'?>
    <!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
    <!--$Header: OpportunityLineDetailsVO.xml 115.20.115200.3 2005/06/20 21:24:25 sekkiral ship $-->
    <ViewObject
    Name="OpportunityLineDetailsVO"
    OrderBy="creation_date"
    BindingStyle="Oracle"
    CustomQuery="true"
    RowClass="oracle.apps.asn.opportunity.server.OpportunityLineDetailsVORowImpl"
    ComponentClass="oracle.apps.asn.common.fwk.server.ASNViewObjectImpl"
    MsgBundleClass="oracle.jbo.common.JboResourceBundle"
    FetchMode="FETCH_AS_NEEDED"
    Passivate="All"
    UseGlueCode="false" >
    <SQLQuery><![CDATA[
    SELECT OpportunityLineEO.lead_id,
    OpportunityLineEO.lead_line_id,
    OpportunityLineEO.inventory_item_id,
    OpportunityLineEO.organization_id,
    OpportunityLineEO.uom_code,
    OpportunityLineEO.quantity,
    OpportunityLineEO.total_amount,
    OpportunityLineEO.forecast_date,
    OpportunityLineEO.creation_date,
    NVL(msit.description,mct.description) AS product_category,
    OpportunityLineEO.object_version_number,
    OpportunityLineEO.product_category_id,
    OpportunityLineEO.product_cat_set_id,
    OpportunityLineEO.attribute_category,
    OpportunityLineEO.attribute1,
    OpportunityLineEO.attribute2,
    OpportunityLineEO.attribute3,
    OpportunityLineEO.attribute4,
    OpportunityLineEO.attribute5,
    OpportunityLineEO.attribute6,
    OpportunityLineEO.attribute7,
    OpportunityLineEO.attribute8,
    OpportunityLineEO.attribute9,
    OpportunityLineEO.attribute10,
    OpportunityLineEO.attribute11,
    OpportunityLineEO.attribute12,
    OpportunityLineEO.attribute13,
    OpportunityLineEO.attribute14,
    OpportunityLineEO.attribute15,
    mskfv.concatenated_segments as item_number
    FROM as_lead_lines_all OpportunityLineEO,
    mtl_system_items_tl msit,
    mtl_categories_tl mct,
         mtl_system_items_b_kfv mskfv
    WHERE OpportunityLineEO.inventory_item_id = msit.inventory_item_id(+)
    AND OpportunityLineEO.organization_id = msit.organization_id (+)
    AND msit.language (+) = USERENV('LANG')
    AND OpportunityLineEO.product_category_id = mct.category_id
    AND mct.language = USERENV('LANG')
    AND mskfv.inventory_item_id (+) = msit.inventory_item_id
    AND mskfv.organization_id (+) = msit.organization_id
    ]]></SQLQuery>
    <DesignTime>
    <Attr Name="_isCodegen" Value="true" />
    <Attr Name="_version" Value="9.0.3.13.68" />
    <Attr Name="_CodeGenFlagNew" Value="4" />
    <Attr Name="_rowSuperClassName" Value="oracle.apps.asn.common.fwk.server.ASNViewRowImpl" />
    <Attr Name="_objectSuperClassName" Value="oracle.apps.asn.common.fwk.server.ASNViewObjectImpl" />
    </DesignTime>
    <EntityUsage
    Name="OpportunityLineEO"
    Entity="oracle.apps.asn.opportunity.schema.server.OpportunityLineEO" >
    <DesignTime>
    <Attr Name="_EntireObjectTable" Value="false" />
    <Attr Name="_queryClause" Value="false" />
    </DesignTime>
    </EntityUsage>
    <ViewAttribute
    Name="LeadId"
    IsUpdateable="while_insert"
    IsNotNull="true"
    EntityAttrName="LeadId"
    EntityUsage="OpportunityLineEO"
    AliasName="LEAD_ID"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="LeadLineId"
    IsUpdateable="while_insert"
    IsNotNull="true"
    EntityAttrName="LeadLineId"
    EntityUsage="OpportunityLineEO"
    AliasName="LEAD_LINE_ID"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="InventoryItemId"
    IsUpdateable="while_insert"
    EntityAttrName="InventoryItemId"
    EntityUsage="OpportunityLineEO"
    AliasName="INVENTORY_ITEM_ID"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="OrganizationId"
    IsUpdateable="while_insert"
    EntityAttrName="OrganizationId"
    EntityUsage="OpportunityLineEO"
    AliasName="ORGANIZATION_ID"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="UomCode"
    EntityAttrName="UomCode"
    EntityUsage="OpportunityLineEO"
    AliasName="UOM_CODE"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Quantity"
    EntityAttrName="Quantity"
    EntityUsage="OpportunityLineEO"
    AliasName="QUANTITY"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="TotalAmount"
    IsNotNull="true"
    EntityAttrName="TotalAmount"
    EntityUsage="OpportunityLineEO"
    AliasName="TOTAL_AMOUNT"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="ForecastDate"
    EntityAttrName="ForecastDate"
    EntityUsage="OpportunityLineEO"
    AliasName="FORECAST_DATE"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="CreationDate"
    IsNotNull="true"
    EntityAttrName="CreationDate"
    EntityUsage="OpportunityLineEO"
    AliasName="CREATION_DATE"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="ProductCategory"
    IsQueriable="false"
    IsPersistent="false"
    Precision="282"
    Type="java.lang.String"
    AliasName="PRODUCT_CATEGORY"
    ColumnType="VARCHAR2"
    Expression="PRODUCT_CATEGORY"
    SQLType="VARCHAR" >
    <DesignTime>
    <Attr Name="_DisplaySize" Value="282" />
    </DesignTime>
    </ViewAttribute>
    <ViewAttribute
    Name="ObjectVersionNumber"
    EntityAttrName="ObjectVersionNumber"
    EntityUsage="OpportunityLineEO"
    AliasName="OBJECT_VERSION_NUMBER"
    Passivate="true"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="ProductCategoryId"
    IsUpdateable="while_insert"
    EntityAttrName="ProductCategoryId"
    EntityUsage="OpportunityLineEO"
    AliasName="ProductCategoryId"
    Passivate="true"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="ProductCatSetId"
    IsUpdateable="while_insert"
    EntityAttrName="ProductCatSetId"
    EntityUsage="OpportunityLineEO"
    AliasName="ProductCatSetId"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="SelectFlag"
    IsPersistent="false"
    Precision="1"
    Type="java.lang.String"
    AliasName="SELECT_FLAG"
    ColumnType="VARCHAR2"
    SQLType="VARCHAR" >
    </ViewAttribute>
    <ViewAttribute
    Name="ItemNullFlag"
    IsPersistent="false"
    Precision="30"
    Type="java.lang.String"
    AliasName="ITEM_NULL_FLAG"
    ColumnType="VARCHAR2"
    SQLType="VARCHAR" >
    </ViewAttribute>
    <ViewAttribute
    Name="ProcOrganizationId"
    IsPersistent="false"
    Type="oracle.jbo.domain.Number"
    AliasName="PROC_ORGANIZATION_ID"
    ColumnType="Number"
    SQLType="NUMERIC" >
    </ViewAttribute>
    <ViewAttribute
    Name="ProcInventoryItemId"
    IsPersistent="false"
    Type="oracle.jbo.domain.Number"
    AliasName="PROC_INVENTORY_ITEM_ID"
    ColumnType="Number"
    SQLType="NUMERIC" >
    </ViewAttribute>
    <ViewAttribute
    Name="EmptyString"
    IsPersistent="false"
    Precision="1"
    Type="java.lang.String"
    AliasName="EMPTY_STRING"
    ColumnType="VARCHAR2"
    SQLType="VARCHAR" >
    </ViewAttribute>
    <ViewAttribute
    Name="AttributeCategory"
    EntityAttrName="AttributeCategory"
    EntityUsage="OpportunityLineEO"
    AliasName="AttributeCategory"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute1"
    EntityAttrName="Attribute1"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute1"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute2"
    EntityAttrName="Attribute2"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute2"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute3"
    EntityAttrName="Attribute3"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute3"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute4"
    EntityAttrName="Attribute4"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute4"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute5"
    EntityAttrName="Attribute5"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute5"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute6"
    EntityAttrName="Attribute6"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute6"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute7"
    EntityAttrName="Attribute7"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute7"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute8"
    EntityAttrName="Attribute8"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute8"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute9"
    EntityAttrName="Attribute9"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute9"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute10"
    EntityAttrName="Attribute10"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute10"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute11"
    EntityAttrName="Attribute11"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute11"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute12"
    EntityAttrName="Attribute12"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute12"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute13"
    EntityAttrName="Attribute13"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute13"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute14"
    EntityAttrName="Attribute14"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute14"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="Attribute15"
    EntityAttrName="Attribute15"
    EntityUsage="OpportunityLineEO"
    AliasName="Attribute15"
    ColumnType="VARCHAR2" >
    </ViewAttribute>
    <ViewAttribute
    Name="OppBestForecastAmount"
    IsQueriable="false"
    IsPersistent="false"
    Precision="255"
    Type="oracle.jbo.domain.Number"
    AliasName="VIEW_ATTR"
    ColumnType="VARCHAR2"
    SQLType="NUMERIC" >
    </ViewAttribute>
    <ViewAttribute
    Name="OppWorstForecastAmount"
    IsQueriable="false"
    IsPersistent="false"
    Precision="255"
    Type="oracle.jbo.domain.Number"
    AliasName="VIEW_ATTR"
    ColumnType="VARCHAR2"
    SQLType="NUMERIC" >
    </ViewAttribute>
    <ViewAttribute
    Name="OppForecastAmount"
    IsQueriable="false"
    IsPersistent="false"
    Precision="255"
    Type="oracle.jbo.domain.Number"
    AliasName="VIEW_ATTR"
    ColumnType="VARCHAR2"
    SQLType="NUMERIC" >
    </ViewAttribute>
    <ViewAttribute
    Name="ItemNumber"
    IsPersistent="false"
    Precision="40"
    Type="java.lang.String"
    AliasName="Item_Number"
    ColumnType="VARCHAR2"
    Expression="Item_Number"
    SQLType="VARCHAR" >
    </ViewAttribute>
    <ViewLinkAccessor
    Name="OpportunityDetailsVO"
    ViewLink="oracle.apps.asn.opportunity.server.OpptyDetailsToLinesVL"
    Type="oracle.jbo.Row"
    Reversed="true"
    IsUpdateable="false" >
    </ViewLinkAccessor>
    <ViewLinkAccessor
    Name="OpptyLineCmptPrdtDetailsVO"
    ViewLink="oracle.apps.asn.opportunity.server.OpptyLineToCmptPrdtDetailsVL"
    Type="oracle.jbo.RowIterator"
    IsUpdateable="false" >
    </ViewLinkAccessor>
    <ViewLinkAccessor
    Name="OpportunityLineNonRevFrcstDetailsVO"
    ViewLink="oracle.apps.asn.opportunity.server.OpptyLineToNonRevFrcstDetailsVL"
    Type="oracle.jbo.RowIterator"
    IsUpdateable="false" >
    </ViewLinkAccessor>
    <ViewLinkAccessor
    Name="OpportunityLineRevFrcstDetailsVO"
    ViewLink="oracle.apps.asn.opportunity.server.OpptyLineToRevFrcstDetailsVL"
    Type="oracle.jbo.RowIterator"
    IsUpdateable="false" >
    </ViewLinkAccessor>
    </ViewObject>
    The corresponding EO.xml file is:
    <?xml version="1.0" encoding='windows-1252'?>
    <!DOCTYPE Entity SYSTEM "jbo_03_01.dtd">
    <Entity
    Name="xxdbdOpportunityCeddEO"
    DBObjectType="table"
    DBObjectName="XXDBD_CEDD"
    AliasName="xxdbdOpportunityCeddEO"
    BindingStyle="Oracle"
    UseGlueCode="false"
    CodeGenFlag="76"
    RowClass="dbdcustom.oracle.apps.asn.opportunity.schema.server.xxdbdOpportunityCeddEOImpl"
    DefClass="oracle.apps.fnd.framework.server.OAEntityDefImpl"
    CollClass="oracle.apps.fnd.framework.server.OAEntityCache" >
    <DesignTime>
    <Attr Name="_isCodegen" Value="true" />
    <Attr Name="_version" Value="9.0.3.13.97" />
    <AttrArray Name="_publishEvents">
    </AttrArray>
    </DesignTime>
    <Attribute
    Name="LeadId"
    IsNotNull="true"
    Type="oracle.jbo.domain.Number"
    ColumnName="LEAD_ID"
    ColumnType="NUMBER"
    SQLType="NUMERIC"
    TableName="XXDBD_CEDD"
    PrimaryKey="true" >
    <DesignTime>
    <Attr Name="_DisplaySize" Value="22" />
    </DesignTime>
    </Attribute>
    <Attribute
    Name="LeadLineId"
    IsNotNull="true"
    Type="oracle.jbo.domain.Number"
    ColumnName="LEAD_LINE_ID"
    ColumnType="NUMBER"
    SQLType="NUMERIC"
    TableName="XXDBD_CEDD"
    PrimaryKey="true" >
    <DesignTime>
    <Attr Name="_DisplaySize" Value="22" />
    </DesignTime>
    </Attribute>
    <Attribute
    Name="CeddDate"
    Type="oracle.jbo.domain.Date"
    ColumnName="CEDD_DATE"
    ColumnType="DATE"
    SQLType="TIMESTAMP"
    TableName="XXDBD_CEDD" >
    <DesignTime>
    <Attr Name="_DisplaySize" Value="7" />
    </DesignTime>
    </Attribute>
    <Key
    Name="XxdbdCeddPk" >
    <AttrArray Name="Attributes">
    <Item Value="dbdcustom.oracle.apps.asn.opportunity.schema.server.xxdbdOpportunityCeddEO.LeadId" />
    <Item Value="dbdcustom.oracle.apps.asn.opportunity.schema.server.xxdbdOpportunityCeddEO.LeadLineId" />
    </AttrArray>
    <DesignTime>
    <Attr Name="_DBObjectName" Value="XXDBD_CEDD_PK" />
    <Attr Name="_isPrimary" Value="true" />
    </DesignTime>
    </Key>
    </Entity>
    Now I extended the VO Object.
    The corresponding VO.xml file is:
    <?xml version="1.0" encoding='windows-1252'?>
    <!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
    <ViewObject
    Name="xxdbdOpportunityLineDetailsVO"
    Extends="oracle.apps.asn.opportunity.server.OpportunityLineDetailsVO"
    OrderBy="CREATION_DATE"
    BindingStyle="Oracle"
    CustomQuery="true"
    RowClass="dbdcustom.oracle.apps.asn.opportunity.server.xxdbdOpportunityLineDetailsVORowImpl"
    ComponentClass="dbdcustom.oracle.apps.asn.opportunity.server.xxdbdOpportunityLineDetailsVOImpl"
    MsgBundleClass="oracle.jbo.common.JboResourceBundle"
    UseGlueCode="false" >
    <SQLQuery><![CDATA[
    SELECT OpportunityLineEO.lead_id LEAD_ID,
    OpportunityLineEO.lead_line_id LEAD_LINE_ID,
    OpportunityLineEO.inventory_item_id,
    OpportunityLineEO.organization_id,
    OpportunityLineEO.uom_code,
    OpportunityLineEO.quantity,
    OpportunityLineEO.total_amount,
    OpportunityLineEO.forecast_date,
    OpportunityLineEO.creation_date,
    NVL(msit.description,mct.description) AS product_category,
    OpportunityLineEO.object_version_number,
    OpportunityLineEO.product_category_id,
    OpportunityLineEO.product_cat_set_id,
    OpportunityLineEO.attribute_category,
    OpportunityLineEO.attribute1,
    OpportunityLineEO.attribute2,
    OpportunityLineEO.attribute3,
    OpportunityLineEO.attribute4,
    OpportunityLineEO.attribute5,
    OpportunityLineEO.attribute6,
    OpportunityLineEO.attribute7,
    OpportunityLineEO.attribute8,
    OpportunityLineEO.attribute9,
    OpportunityLineEO.attribute10,
    OpportunityLineEO.attribute11,
    OpportunityLineEO.attribute12,
    OpportunityLineEO.attribute13,
    OpportunityLineEO.attribute14,
    OpportunityLineEO.attribute15,
    mskfv.concatenated_segments as item_number,
    xxdbdOpportunityCeddEO.cedd_date
    FROM as_lead_lines_all OpportunityLineEO,
    mtl_system_items_tl msit,
    mtl_categories_tl mct,
    mtl_system_items_b_kfv mskfv,
    xxdbd_cedd xxdbdOpportunityCeddEO
    WHERE OpportunityLineEO.inventory_item_id = msit.inventory_item_id(+)
    AND OpportunityLineEO.LEAD_ID=xxdbdOpportunityCeddEO.LEAD_ID
    and OpportunityLineEO.LEAD_LINE_ID=xxdbdOpportunityCeddEO.LEAD_LINE_ID
    AND OpportunityLineEO.organization_id = msit.organization_id (+)
    AND msit.language (+) = USERENV('LANG')
    AND OpportunityLineEO.product_category_id = mct.category_id
    AND mct.language = USERENV('LANG')
    AND mskfv.inventory_item_id (+) = msit.inventory_item_id
    AND mskfv.organization_id (+) = msit.organization_id
    ]]></SQLQuery>
    <DesignTime>
    <Attr Name="_isCodegen" Value="true" />
    <Attr Name="_version" Value="9.0.3.13.97" />
    <Attr Name="_CodeGenFlagNew" Value="36" />
    </DesignTime>
    <EntityUsage
    Name="xxdbdOpportunityCeddEO"
    Entity="dbdcustom.oracle.apps.asn.opportunity.schema.server.xxdbdOpportunityCeddEO"
    SourceUsage="oracle.apps.asn.opportunity.server.OpportunityLineDetailsVO.OpportunityLineEO"
    Reference="true" >
    <DesignTime>
    <Attr Name="_queryClause" Value="false" />
    <AttrArray Name="_srcAttributes">
    <Item Value="oracle.apps.asn.opportunity.schema.server.OpportunityLineEO.LeadLineId" />
    <Item Value="oracle.apps.asn.opportunity.schema.server.OpportunityLineEO.LeadId" />
    </AttrArray>
    <AttrArray Name="_dstAttributes">
    <Item Value="dbdcustom.oracle.apps.asn.opportunity.schema.server.xxdbdOpportunityCeddEO.LeadLineId" />
    <Item Value="dbdcustom.oracle.apps.asn.opportunity.schema.server.xxdbdOpportunityCeddEO.LeadId" />
    </AttrArray>
    </DesignTime>
    </EntityUsage>
    <ViewAttribute
    Name="ProductCategory"
    IsQueriable="false"
    IsPersistent="false"
    Precision="282"
    Type="java.lang.String"
    ColumnType="VARCHAR2"
    AliasName="PRODUCT_CATEGORY"
    Expression="PRODUCT_CATEGORY"
    SQLType="VARCHAR" >
    <DesignTime>
    <Attr Name="_OverrideAttr" Value="true" />
    <Attr Name="_DisplaySize" Value="282" />
    </DesignTime>
    </ViewAttribute>
    <ViewAttribute
    Name="SelectFlag"
    IsPersistent="false"
    Precision="1"
    Type="java.lang.String"
    ColumnType="VARCHAR2"
    AliasName="SELECT_FLAG"
    SQLType="VARCHAR" >
    <DesignTime>
    <Attr Name="_OverrideAttr" Value="true" />
    </DesignTime>
    </ViewAttribute>
    <ViewAttribute
    Name="ItemNullFlag"
    IsPersistent="false"
    Precision="30"
    Type="java.lang.String"
    ColumnType="VARCHAR2"
    AliasName="ITEM_NULL_FLAG"
    SQLType="VARCHAR" >
    <DesignTime>
    <Attr Name="_OverrideAttr" Value="true" />
    </DesignTime>
    </ViewAttribute>
    <ViewAttribute
    Name="ProcOrganizationId"
    IsPersistent="false"
    Type="oracle.jbo.domain.Number"
    ColumnType="Number"
    AliasName="PROC_ORGANIZATION_ID"
    SQLType="NUMERIC" >
    <DesignTime>
    <Attr Name="_OverrideAttr" Value="true" />
    </DesignTime>
    </ViewAttribute>
    <ViewAttribute
    Name="ProcInventoryItemId"
    IsPersistent="false"
    Type="oracle.jbo.domain.Number"
    ColumnType="Number"
    AliasName="PROC_INVENTORY_ITEM_ID"
    SQLType="NUMERIC" >
    <DesignTime>
    <Attr Name="_OverrideAttr" Value="true" />
    </DesignTime>
    </ViewAttribute>
    <ViewAttribute
    Name="EmptyString"
    IsPersistent="false"
    Precision="1"
    Type="java.lang.String"
    ColumnType="VARCHAR2"
    AliasName="EMPTY_STRING"
    SQLType="VARCHAR" >
    <DesignTime>
    <Attr Name="_OverrideAttr" Value="true" />
    </DesignTime>
    </ViewAttribute>
    <ViewAttribute
    Name="OppBestForecastAmount"
    IsQueriable="false"
    IsPersistent="false"
    Precision="255"
    Type="oracle.jbo.domain.Number"
    ColumnType="VARCHAR2"
    AliasName="VIEW_ATTR"
    SQLType="NUMERIC" >
    <DesignTime>
    <Attr Name="_OverrideAttr" Value="true" />
    </DesignTime>
    </ViewAttribute>
    <ViewAttribute
    Name="OppWorstForecastAmount"
    IsQueriable="false"
    IsPersistent="false"
    Precision="255"
    Type="oracle.jbo.domain.Number"
    ColumnType="VARCHAR2"
    AliasName="VIEW_ATTR"
    SQLType="NUMERIC" >
    <DesignTime>
    <Attr Name="_OverrideAttr" Value="true" />
    </DesignTime>
    </ViewAttribute>
    <ViewAttribute
    Name="OppForecastAmount"
    IsQueriable="false"
    IsPersistent="false"
    Precision="255"
    Type="oracle.jbo.domain.Number"
    ColumnType="VARCHAR2"
    AliasName="VIEW_ATTR"
    SQLType="NUMERIC" >
    <DesignTime>
    <Attr Name="_OverrideAttr" Value="true" />
    </DesignTime>
    </ViewAttribute>
    <ViewAttribute
    Name="ItemNumber"
    IsPersistent="false"
    Precision="40"
    Type="java.lang.String"
    ColumnType="VARCHAR2"
    AliasName="Item_Number"
    Expression="Item_Number"
    SQLType="VARCHAR" >
    <DesignTime>
    <Attr Name="_OverrideAttr" Value="true" />
    </DesignTime>
    </ViewAttribute>
    <ViewAttribute
    Name="CeddDate"
    IsPersistent="false"
    Type="oracle.jbo.domain.Date"
    ColumnType="DATE"
    AliasName="CeddDate"
    Expression="Cedd_Date"
    SQLType="DATE" >
    </ViewAttribute>
    </ViewObject>
    Now my question is : Do I need to substitute the EO with the new EO that i have developed??
    And then how to proceed further.
    Please help me. This is very urgent.
    Thanx in advance.

    I have created a New EO for the custom table.
    And I have extended VO. The VO query has been changed as below:
    Original VO Query:
    SELECT OpportunityLineEO.lead_id,
    OpportunityLineEO.lead_line_id,
    OpportunityLineEO.inventory_item_id,
    OpportunityLineEO.organization_id,
    OpportunityLineEO.uom_code,
    OpportunityLineEO.quantity,
    OpportunityLineEO.total_amount,
    OpportunityLineEO.forecast_date,
    OpportunityLineEO.creation_date,
    NVL(msit.description,mct.description) AS product_category,
    OpportunityLineEO.object_version_number,
    OpportunityLineEO.product_category_id,
    OpportunityLineEO.product_cat_set_id,
    OpportunityLineEO.attribute_category,
    OpportunityLineEO.attribute1,
    OpportunityLineEO.attribute2,
    OpportunityLineEO.attribute3,
    OpportunityLineEO.attribute4,
    OpportunityLineEO.attribute5,
    OpportunityLineEO.attribute6,
    OpportunityLineEO.attribute7,
    OpportunityLineEO.attribute8,
    OpportunityLineEO.attribute9,
    OpportunityLineEO.attribute10,
    OpportunityLineEO.attribute11,
    OpportunityLineEO.attribute12,
    OpportunityLineEO.attribute13,
    OpportunityLineEO.attribute14,
    OpportunityLineEO.attribute15,
    mskfv.concatenated_segments as item_number
    FROM as_lead_lines_all OpportunityLineEO,
    mtl_system_items_tl msit,
    mtl_categories_tl mct,
         mtl_system_items_b_kfv mskfv
    WHERE OpportunityLineEO.inventory_item_id = msit.inventory_item_id(+)
    AND OpportunityLineEO.organization_id = msit.organization_id (+)
    AND msit.language (+) = USERENV('LANG')
    AND OpportunityLineEO.product_category_id = mct.category_id
    AND mct.language = USERENV('LANG')
    AND mskfv.inventory_item_id (+) = msit.inventory_item_id
    AND mskfv.organization_id (+) = msit.organization_id
    New VO Query is:
    SELECT OpportunityLineEO.lead_id LEAD_ID,
    OpportunityLineEO.lead_line_id LEAD_LINE_ID,
    OpportunityLineEO.inventory_item_id,
    OpportunityLineEO.organization_id,
    OpportunityLineEO.uom_code,
    OpportunityLineEO.quantity,
    OpportunityLineEO.total_amount,
    OpportunityLineEO.forecast_date,
    OpportunityLineEO.creation_date,
    NVL(msit.description,mct.description) AS product_category,
    OpportunityLineEO.object_version_number,
    OpportunityLineEO.product_category_id,
    OpportunityLineEO.product_cat_set_id,
    OpportunityLineEO.attribute_category,
    OpportunityLineEO.attribute1,
    OpportunityLineEO.attribute2,
    OpportunityLineEO.attribute3,
    OpportunityLineEO.attribute4,
    OpportunityLineEO.attribute5,
    OpportunityLineEO.attribute6,
    OpportunityLineEO.attribute7,
    OpportunityLineEO.attribute8,
    OpportunityLineEO.attribute9,
    OpportunityLineEO.attribute10,
    OpportunityLineEO.attribute11,
    OpportunityLineEO.attribute12,
    OpportunityLineEO.attribute13,
    OpportunityLineEO.attribute14,
    OpportunityLineEO.attribute15,
    mskfv.concatenated_segments as item_number,
    xxdbdOpportunityCeddEO.cedd_date
    FROM as_lead_lines_all OpportunityLineEO,
    mtl_system_items_tl msit,
    mtl_categories_tl mct,
         mtl_system_items_b_kfv mskfv,
              xxdbd_cedd xxdbdOpportunityCeddEO
    WHERE OpportunityLineEO.inventory_item_id = msit.inventory_item_id(+)
    AND OpportunityLineEO.LEAD_ID=xxdbdOpportunityCeddEO.LEAD_ID
    and OpportunityLineEO.LEAD_LINE_ID=xxdbdOpportunityCeddEO.LEAD_LINE_ID
    AND OpportunityLineEO.organization_id = msit.organization_id (+)
    AND msit.language (+) = USERENV('LANG')
    AND OpportunityLineEO.product_category_id = mct.category_id
    AND mct.language = USERENV('LANG')
    AND mskfv.inventory_item_id (+) = msit.inventory_item_id
    AND mskfv.organization_id (+) = msit.organization_id
    I have substituted the new VO with the old one.Then through personalition, i have added a new field and assigned cedd_date to the field.
    But when i open the page, when i create a line, all the values are going to the first able but this date value is not going to the custom table.
    Can someone please help me in this. This is very urgent.
    Thanx in advance.

  • Need help creating a device collection based on members of a user collection

    Hello everyone,
        I am working on developing a device collection based on the membership of a user collection. The purpose of the device collection is to provide us with the capability of deploying software to users while the users are logged off their systems.
    I would love to use AD security groups but unfortunately that isn't an available approach in this case. I have been experimenting with SQL queries to find the best way to obtain the results I want and the following query works like a champ:
    Select SYS.Name0,
    v_R_User.Unique_User_Name0
    FROM v_R_System AS SYS
    JOIN v_UserMachineRelationship ON SYS.Name0=v_UserMachineRelationship.MachineResourceName
    JOIN v_R_User ON v_UserMachineRelationship.UniqueUserName=v_R_User.Unique_User_Name0
    JOIN v_FullCollectionMembership AS FCM on FCM.ResourceID = v_R_User.ResourceID
    JOIN v_Collection AS COLMEM ON COLMEM.CollectionID = FCM.CollectionID
    Where FCM.CollectionID = 'cha0000B'
    The problem arises when I attempt this same query in SCCM 2012, I don't get any results from this query so of course it won't work to base a Device Collection from. Here is the WQL:
    Select SYS.Name,
    SMS_R_User.UniqueUserName
    FROM SMS_R_System AS SYS
    JOIN SMS_UserMachineRelationship ON SYS.Name=SMS_UserMachineRelationship.MachineResourceName
    JOIN SMS_R_User ON SMS_UserMachineRelationship.UniqueUserName=SMS_R_User.UniqueUserName
    join sms_v_FullCollectionMembership AS FCM on FCM.ResourceID = SMS_R_User.ResourceID
    join SMS_v_Collection AS COLMEM ON COLMEM.CollectionID = FCM.CollectionIDwhere FCM.CollectionID = 'cha0000B'
    I am hoping that someone will be able to look at my SQL and tell me how I can get the WQL right so I can use this query properly or provide suggestions to accomplish what I need.
    Thanks in advance for the assist,
    Chris Bolton

    Hi Torsten,
         While your suggestion of that link was close, it still went in the direction of using security groups as the basis for device queries and that isn't the direction I am pursuing. I had a colleague look at my original query and he identified
    that I had some unnecessary redundancy but that didn't resolve my SQL -> WQL inconsistency. I continued to play with the query and the following SQL also works (and actually works a bit better for my purposes)
    select distinct v_R_System.Name0,
    v_R_User.Unique_User_Name0
    FROM v_R_System
    JOIN v_R_User on v_R_User.Full_User_Name0 = v_R_System.User_Name0
    JOIN v_UserMachineRelationship ON v_R_System.Name0 = v_UserMachineRelationship.MachineResourceName
    JOIN v_FullCollectionMembership on v_R_User.Unique_User_Name0 = v_FullCollectionMembership.SMSID
    WHERE v_FullCollectionMembership.CollectionID = 'cha0000b'
    however when I translate it to WQL I still am unable to get results (here is the WQL version)
    select distinct sms_R_system.Name,
    sms_R_User.UniqueUserName
    FROM sms_R_system
    JOIN SMS_R_User on SMS_R_User.FullUserName = SMS_R_System.UserName
    JOIN SMS_UserMachineRelationship ON SMS_R_System.Name = SMS_UserMachineRelationship.MachineResourceName
    JOIN SMS_FullCollectionMembership on SMS_R_User.UniqueUserName = SMS_FullCollectionMembership.SMSID
    WHERE SMS_FullCollectionMembership.CollectionID = 'cha0000b'
    I think I am on the verge of getting this right but it sure seems to be a challenge. Is there a "WQL Workbench" that I could use that is similar to SQL Management Studio inside of which I could test these queries rather than having to use the rather clunky
    SCCM "Edit Query Statement" dialog box?
    Thanks again,
    Chris Bolton

  • Need Help on Filtering a column

    Hi below is my requirement.
    ColA ColB ColB
    In the above, both the column 2 and 3 are the same columns, but i need to filter the column 3 alone based on another column. Please help.

    Hi,
    Write a case statement on 3rd column ...
    case when table1.status = 'Complete' then value(2nd col) end
    or
    case when table1.status = 'Complete' then value(2nd col) else null end
    Updated Post
    Can you paste your code (case statement)
    case when table_name.status ='Complete' then table_name.value end
    or
    case when table_name.status ='Complete' then table_name.value else null end
    Cheers,
    Aravind
    Edited by: Aravind Addala on May 17, 2011 11:48 PM

  • Need help in Bind variable in AF Query LOV

    Hi,
    i have one problem with bind variable, if i use bind variable in the LOV VO Query then my result is not coming, if there is not bind variable it's working fine and if i use the bind variable in the LOV search option then it's working fine but if i hide the bind variable and set the value in AM prepareSesstion method the LOV is not returning any value. I try to return the values also all values are also coming but those values are not setting to AF Query Attribute.
    Query is:
    select substr(d.description,0,40) description
    from cm_system_users a,
    cm_user_responsibilities b,
    cm_responsibility_processes c,
    cm_processes d
    where a.nt_login =:B_NT_LOGIN
    and a.user_id = b.user_id
    and trunc(sysdate) between b.eff_date and nvl(b.exp_date,sysdate + 1)
    and b.RESPONSIBILITY_ID = c.RESPONSIBILITY_ID
    and c.process_type = d.process_type
    and d.enabled_flag = 'Y' order by d.arguments_flag
    AM Method:
    CmProcessViewImpl vo = getCmProcessView();
    String nt_login = getUserPrincipalName();
    vo.setNamedWhereClauseParam("B_NT_LOGIN", nt_login.toUpperCase());
    vo.executeQuery();
    Can any one help me in this. it's urgent for me.

    This is a little underdescribed. IIUC, the view object in question is being used as a target for a view accessor, correct? (Otherwise you'll have to be more explicit about what you mean by "Query LOV".
    If I'm right, there are two possibilities:
    1) You are using a VO instance in a shared application module instance. If so, make sure your code is in the prepareSession() for that application module class if it's session dependent (as it seems to be below), you need to make sure the application module instance is shared at session scope.
    2) You've based the view accessor directly on the VO definition. This basically creates an anonymous VO instance; I don't think there's any way to use prepareSession() to set a bind variable on such an instance (which won't be created until the accessor is first used). You might be able to get by with putting similar code into the view object class' create() method, but I haven't tested this.
    If your code is in your primary application module class (as opposed to the class for a shared AM instance), the problem here is that getCmProcessView() returns the VO instance from that application module instance's design-time data model, which is never used by view accessors.
    By the way, why do you need to do this in prepareSession() instead of at the view accessor level? I believe you can get the logged in user name (for the view accessor) in with the groovy expression
    viewObject.DBTransaction.session.userPrincipalName
    or possibly just
    DBTransaction.session.userPrincipalName
    (despite this involving DBTransaction, it returns the web app user name, not the DB username).
    That's a 100% declarative solution, if you don't count the Groovy expression as non-declarative.
    If you're afraid of a user executing the LOV (somehow) before the bind variable value gets set, just ensure that the bind variable is marked "required".

  • Need help with a calculated column - is there any way to reference a value in the current row?

    Hey guys,
    I'm a bit of a DAX newbie, and I'm running into a block. I'm creating a Power View report about IT tickets. We are going to be creating a cube to automate the data soon, I'm currently working with a flat Excel Data Table of data to demonstrate the Power
    View reporting capabilities to the team. I need the default display to show the top 4-5 items basked on the Ticket Count. The three applicable columns I'm using are the TicketID, the ContactReason, and the AssetCategory - all three are
    text. One slide will show the top five Contact Reasons by Ticket Count, and the other will show the top five Categories by Ticket Count. The users will see this default view, but will be able to change it to see differently ranked items or can clear the
    ranking slicer altogether.
    What I've accomplished so far is to create the Calculated Field [Ticket Count] = COUNTA(Table1[TicketID])
    And 2 other calculated fields:
    [Contact Rank] = RANKX(ALL(Table1[ContactReason]),[Ticket Count],,,DENSE)
    [Asset Rank] = RANKX(ALL(Table1[AssetCategory]),[Ticket Count],,,DENSE)
    If I were creating a Pivot Table, this would be great. These fields calculate everything the right way. The problem is, I need to have a Rank slicer on each slide and the calculation by itself contains no data - with no data, there's nothing to slice. I
    realized I need to actually have columns of data so I can create a slicer. I need each row of the table to show the same [Contact Rank] for every instance of a particular ContactReason (and the same for the [Asset Rank] and AssetCategory).
    The RANKX formulas pasted into the Calculated Column section only show a value of 1 - with no Pivot table summarizing the fields, it's counting each row's ticket once, giving every line the tied Rank of #1.
    I've solved the problem in Excel by creating 2 Pivot Tables on a separate sheet that have the data field and the calculated field for ContactRason and AssetCategory. Then on my Excel Data Table, I've added two columns that do a VLOOKUP and pull over a the
    Calculated Rank from each Pivot Table that match the ContactReason and AssetCategory fields. This works on the flat Excel Data Table now, but will not be a solutions when we start pulling the data from the cube (and there is no flat table).
    What I think I need is an Expression for the RANKX formula that can give me, for each row, the count of all of the times a ContactReason shows up in an entire column. There's only about 100,000 lines of data and each ContactReason or AssetCategory
    may show up several thousand times. But if I can get the expression to return that count, then the RANKX formula should work in the Column. If it wasn't a DAX formula, I'd use a COUNTIF and say 'Count the entire ContactReason column anytime it's equal to the
    ContactReason on THIS row', but in DAX I don't know how to reference a single value in a row. I've tried the CALCULATE() formula, but it seems like the filter needs a specific value, and doesn't work on a dynamic "cell" value.
    Any help would be greatly appreciated! (I hope it all makes sense!)

    If I've understood you correctly then the ALLEXCEPT function may be what you're after and it could be applied in a similar way to the following...
    =
    RANKX(
    ALL(Table1),
    CALCULATE(
    COUNTROWS(table1),
    ALLEXCEPT(Table1, Table1[ContactReason])
    DENSE
    If this has missed the mark, would it be possible to clarify the requirement further?
    Regards,
    Michael Amadi
    Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to vote it as helpful :)
    Website: http://www.nimblelearn.com
    Blog: http://www.nimblelearn.com/blog
    Twitter: @nimblelearn

  • Need help in sorting a column in classic report

    Hi I am trying to create and classic report and I need to do sorting on the columns. Also I am using a select list to filter the records in the column. When I am not using the select list the sorting is working but when I am using the selcet list and select the sort option then it is showing error. Can anyone help...
    Thnaks,
    Rik

    Select lists prior to v4 will sort on the return value. In v4, it sorts on the display value (as you're probably expecting). There's nothing really for you to fix here except if it's really important, see if you can get upgraded to v4.

Maybe you are looking for

  • Matrix-style lines on DVD display

    Is anyone acquainted with this? Vertical lines in the style of The Matrix appear when a DVD is played but only on the image. For example, the lines do not appear in the border if the image is set to wide screen or if the video is watched in a window

  • How to make Applet working -.

    I am trying to use an Applet from web. ( http://www.sanger.ac.uk/Users/kmr/d/start.html ) What are the softwares i should install inorder to make the Applet working ? . or is it problem of Applet? In all the machines in our network the applet is not

  • When emailing from iPhoto I keep on getting 'server not responded' message.

    Would anyone be able to help with the issue I have with iPhoto. Every time I try to email photos directly from iPhoto I get this message 'server not responded'. I have the lates Mountain Lion OSX installed on MBA. Also, in addition to iCloud account

  • Restore Validate Database vs Backup Validate Database

    Hi, I want to add the following sentence after taking the backup using following command (backup as compressed backupset database plus archivelog;) restore database validate; or backup validate database; which one is best?

  • 30GB won't work...no matter what :-(

    My 30GB black iPod hasn't worked in days, it won't respond. I thought the battery was fully drained so I left it plugged into the computer all night and I wake up to see it still doesn't work. The computer didn't even recognize it, no removable hardw