Query Please Urgent

SELECT DISTINCT icms_task_assigned.task,icms_task_department.task_department,icms_assigned_to.assigned_to,to_char(icms_task_assigned.target_date,'DD-Mon-YYYY') AS target_date,call_status,icms_task_assigned.remarks,icms_task_assigned.task_id FROM icms_task_assigned LEFT JOIN icms_task_department ON icms_task_department.task_department_id = icms_task_assigned.department LEFT JOIN icms_assigned_to ON icms_assigned_to.assigned_to_id = icms_task_assigned.assigned_to WHERE icms_users.user_id = 1 AND to_char(icms_task_assigned.assigned_date,'YYYY-MM-DD') >= '2006-07-01' AND to_char(icms_task_assigned.assigned_date,'YYYY-MM-DD') <= '2006-07-14' ORDER BY UPPER(target_date)
The error is
ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list

You can't use the alias in the order by clause. And what about :
SCOTT@demo102> select ename,
  2                   case when sal >= 30000 then 'Very high'
  3                        when sal >= 20000 then 'High'
  4                        when sal >= 10000 then 'Medium'
  5                        else 'Low' end as SalStatus
  6            from emp
  7            order by SalStatus;
ENAME      SALSTATUS
CLARK      High
BLAKE      High
JONES      High
JAMES      Low
SMITH      Low
ALLEN      Medium
WARD       Medium
MILLER     Medium
MARTIN     Medium
TURNER     Medium
ADAMS      Medium
SCOTT      Very high
FORD       Very high
KING       Very high
14 rows selected.
SCOTT@demo102> Nicolas.

Similar Messages

  • Problem in query : please urgent

    Hi I have this query , all the address_id i am selecting from 3 tables i want to match to another table address where i have to match adrress_id from address table to all the diffrerent address_ids from subquery . But i am getting too many values error . Please help me in writing this query.
    select * from address where address_id in (select sh.a_address_id,sh.b_address_id,ph.home_address_id,
    ph.work_address_id,cnh.site_address_id,cnh.postal_address_id,
    ph.Postal_address_id from service_history@sppmig1 sh, person_history@sppmig1 ph , customer_node_history@sppmig1 cnh where
    ph.person_id in ( select person_id from temp_customer_node_history ) and
    ph.person_id=cnh.person_id and sh.customer_node_id=cnh.customer_node_id)

    select * from address where address_id a
    WHERE exists (select 1FROM service_history@sppmig1 sh, person_history@sppmig1 ph , customer_node_history@sppmig1 cnh
    WHERE
    ((a.address_id = sh.a_address_id) or (a.adress_id = sh.b_address_id)
    or .....) and
    ph.person_id in ( select person_id from temp_customer_node_history ) and
    ph.person_id=cnh.person_id and sh.customer_node_id=cnh.customer_node_id)

  • How to improve the performance of the attached query, Please help

    Hi,
    How to improve performance of the below query, Please help. also attached explain plan -
    SELECT Camp.Id,
    rCam.AccountKey,
    Camp.Id,
    CamBilling.Cpm,
    CamBilling.Cpc,
    CamBilling.FlatRate,
    Camp.CampaignKey,
    Camp.AccountKey,
    CamBilling.billoncontractedamount,
    (SUM(rCam.Impressions) * 0.001 + SUM(rCam.Clickthrus)) AS GR,
    rCam.AccountKey as AccountKey
    FROM Campaign Camp, rCamSit rCam, CamBilling, Site xSite
    WHERE Camp.AccountKey = rCam.AccountKey
    AND Camp.AvCampaignKey = rCam.AvCampaignKey
    AND Camp.AccountKey = CamBilling.AccountKey
    AND Camp.CampaignKey = CamBilling.CampaignKey
    AND rCam.AccountKey = xSite.AccountKey
    AND rCam.AvSiteKey = xSite.AvSiteKey
    AND rCam.RmWhen BETWEEN to_date('01-01-2009', 'DD-MM-YYYY') and
    to_date('01-01-2011', 'DD-MM-YYYY')
    GROUP By rCam.AccountKey,
    Camp.Id,
    CamBilling.Cpm,
    CamBilling.Cpc,
    CamBilling.FlatRate,
    Camp.CampaignKey,
    Camp.AccountKey,
    CamBilling.billoncontractedamount
    Explain Plan :-
    Description                    Object_owner          Object_name     Cost     Cardinality     Bytes     
    SELECT STATEMENT, GOAL = ALL_ROWS                              14     1     13
    SORT AGGREGATE                                                  1     13
    VIEW                         GEMINI_REPORTING               14     1     13
    HASH GROUP BY                                        14     1     103
    NESTED LOOPS                                        13     1     103
    HASH JOIN                                             12     1     85
    TABLE ACCESS BY INDEX ROWID     GEMINI_REPORTING     RCAMSIT          2     4     100
    NESTED LOOPS                                        9     5     325
    HASH JOIN                                        7     1     40
    SORT UNIQUE                                        2     1     18
    TABLE ACCESS BY INDEX ROWID     GEMINI_PRIMARY          SITE          2     1     18
    INDEX RANGE SCAN          GEMINI_PRIMARY          SITE_I0          1     1     
    TABLE ACCESS FULL          GEMINI_PRIMARY          SITE          3     27     594
    INDEX RANGE SCAN          GEMINI_REPORTING     RCAMSIT_I     1     1     5     
    TABLE ACCESS FULL     GEMINI_PRIMARY     CAMPAIGN                    3     127     2540
    TABLE ACCESS BY INDEX ROWID     GEMINI_PRIMARY          CAMBILLING     1     1     18
    INDEX UNIQUE SCAN     GEMINI_PRIMARY     CAMBILLING_U1                    0     1

    Hello,
    This has really nothing to do with the Oracle Forms product.
    Please, send the SQL or/and PL/SQL questions in the corresponding forums.
    Francois

  • Suggest the query to this tricky query please

    Hi people,
    I just got a query which is a brain tease for me (not all).
    that is
    sql> select * from mytab;
    sql> no name
    1 asuri
    1 prasanth
    2 brian
    2 lara
    the above is query is returned by the sql;
    here 1 and 2 are duplicated values;
    now output required is
    sql>no name
    1 asuri prasanth
    2 brain lara
    Is this possible with a single sql query;
    please tell me solution
    regards
    prasanth

    How do find that it should be brian lara not lara brian..
    But any way the following will do ...SQL> select * from mytab;
    A NAME
    1 asuri
    1 prasanth
    2 brian
    2 lara
    SQL> select a,name||' '||name2 name from
    2 (
    3 select a,name,lead(name) over (partition by a order by a) name2 from mytab)
    4 where name2 is not null;
    A NAME
    1 asuri prasanth
    2 brian lara
    The names by above query can be returned as 'lara brian' and 'prasanth asuri' as there is no way telling which one is a surname..

  • Patch for bug 5397515 or alternate for query please

    Hi
    I am running following query on 10.2.0.3 but giving me internal error. Came to know that its a bug 5397515 fixed in 10.2.0.4. I want to know is there any patch available to resolve just this bug without shifting to 10.2.0.4. or any alternate for this query please??
    SELECT AB.SHIPMENT_LINE_ID, AB.TRANSACTION_ID
    FROM RCV_TRANSACTIONS AB
    WHERE AB.TRANSACTION_TYPE = 'RECEIVE'
    AND AB.SHIPMENT_LINE_ID NOT IN
    (select
    RTS.SHIPMENT_LINE_ID
    from RCV_TRANSACTIONS RTS
    WHERE (LEVEL = 2 OR
    LEVEL =
    select MAX(LEVEL)
    from RCV_TRANSACTIONS B
    start with B.TRANSACTION_ID = 133847
    connect by PRIOR B.TRANSACTION_ID = B.PARENT_TRANSACTION_ID))
    AND RTS.TRANSACTION_TYPE IN ('REJECT',
    'RETURN TO CUSTOMER',
    'RETURN TO VENDOR',
    'CORRECT')
    HAVING ABS(SUM(RTS.QUANTITY)) = AB.QUANTITY
    start with RTS.TRANSACTION_ID = 133847
    connect by PRIOR RTS.TRANSACTION_ID = RTS.PARENT_TRANSACTION_ID
    GROUP BY RTS.SHIPMENT_LINE_ID
    AND AB.TRANSACTION_ID = 133847
    regards

    >
    SELECT AB.SHIPMENT_LINE_ID, AB.TRANSACTION_ID
    FROM RCV_TRANSACTIONS AB
    WHERE AB.TRANSACTION_TYPE = 'RECEIVE'
    AND AB.SHIPMENT_LINE_ID NOT IN
    (select
    RTS.SHIPMENT_LINE_ID
    from RCV_TRANSACTIONS RTS
    WHERE (LEVEL = 2 OR
    LEVEL =
    select MAX(LEVEL)
    from RCV_TRANSACTIONS B
    start with B.TRANSACTION_ID = 133847
    connect by PRIOR B.TRANSACTION_ID = B.PARENT_TRANSACTION_ID))
    AND RTS.TRANSACTION_TYPE IN ('REJECT',
    'RETURN TO CUSTOMER',
    'RETURN TO VENDOR',
    'CORRECT')
    HAVING ABS(SUM(RTS.QUANTITY)) = AB.QUANTITY
    start with RTS.TRANSACTION_ID = 133847
    connect by PRIOR RTS.TRANSACTION_ID = RTS.PARENT_TRANSACTION_ID
    GROUP BY RTS.SHIPMENT_LINE_ID
    AND AB.TRANSACTION_ID = 133847
    >
    Are you sure this query is returning an internal error. As far as I know you can use the level keyword only when there is a connect by involved in the same level of the statement.
    For example following sql statement returns me an error.
    SQL> select * from dual where level = 2 or level = (select max(level) from dual connect by level <= 10);
    select * from dual where level = 2 or level = (select max(level) from dual connect by level <= 10)
    ERROR at line 1:
    ORA-01788: CONNECT BY clause required in this query blockI am not able to find the bug in the metalink.
    If you could copy & paste the actual error (not the contents of the trace file) and explain briefly what you are trying to achieve it will aid us in suggesting you with a solution.
    Regards
    Raj

  • I just paid my monthly fee but it keeps saying i haven't, so i can't use the apps?? please urgent help...

    i just paid my monthly fee but it keeps saying i haven't, so i can't use the apps?? please urgent help...

    Hi there
    Your Adobe ID is still associated with an older expired membership.  Please sign out of the CC desktop app and sign in again with your Adobe ID to activate the new membership plan.
    Sign out, Sign in | Creative Cloud Desktop app
    Thanks
    Bev

  • Got error id 502 with photoshop cc 2014 mac V.15.2.2 (15.2.2.310)?? latest version install, please urgent.

    got error id 502 with photoshop cc 2014 mac V.15.2.2 (15.2.2.310)?? latest version install, please urgent.??????
    Process:         Adobe Photoshop CC 2014 [851]
    Path:            /Applications/Adobe Photoshop CC 2014/Adobe Photoshop CC 2014.app/Contents/MacOS/Adobe Photoshop CC 2014
    Identifier:      com.adobe.Photoshop
    Version:         15.2.2 (15.2.2.310)
    Code Type:       X86-64 (Native)
    Parent Process:  launchd [146]
    Responsible:     Adobe Photoshop CC 2014 [851]
    User ID:         502
    Date/Time:       2015-02-06 10:27:25.031 +0400
    OS Version:      Mac OS X 10.9.5 (13F34)
    Report Version:  11
    Anonymous UUID:  817D6DB9-94A0-9F64-CA93-F771A1C7B832
    Crashed Thread:  0 Dispatch queue: com.apple.main-thread
    Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
    Exception Codes: KERN_INVALID_ADDRESS at 0x00000000000001a0
    VM Regions Near 0x1a0:
    -->
    __TEXT                 0000000104662000-0000000108f3f000 [ 72.9M] r-x/rwx SM=COW  /Applications/Adobe Photoshop CC 2014/Adobe Photoshop CC 2014.app/Contents/MacOS/Adobe Photoshop CC 2014

    got error id 502 with photoshop cc 2014 mac V.15.2.2 (15.2.2.310)?? latest version install, please urgent.??????
    Process:         Adobe Photoshop CC 2014 [851]
    Path:            /Applications/Adobe Photoshop CC 2014/Adobe Photoshop CC 2014.app/Contents/MacOS/Adobe Photoshop CC 2014
    Identifier:      com.adobe.Photoshop
    Version:         15.2.2 (15.2.2.310)
    Code Type:       X86-64 (Native)
    Parent Process:  launchd [146]
    Responsible:     Adobe Photoshop CC 2014 [851]
    User ID:         502
    Date/Time:       2015-02-06 10:27:25.031 +0400
    OS Version:      Mac OS X 10.9.5 (13F34)
    Report Version:  11
    Anonymous UUID:  817D6DB9-94A0-9F64-CA93-F771A1C7B832
    Crashed Thread:  0 Dispatch queue: com.apple.main-thread
    Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
    Exception Codes: KERN_INVALID_ADDRESS at 0x00000000000001a0
    VM Regions Near 0x1a0:
    -->
    __TEXT                 0000000104662000-0000000108f3f000 [ 72.9M] r-x/rwx SM=COW  /Applications/Adobe Photoshop CC 2014/Adobe Photoshop CC 2014.app/Contents/MacOS/Adobe Photoshop CC 2014

  • HT1918 hey am stranded its like a month now my account does not have  the None in the payment type section i had put my visa info but not now i want to remove them please urgent help

    hey am stranded its like a month now my account does not have  the None in the payment type section i had put my visa info but not now i want to remove them please urgent help

    iTunes Store Support
    http://www.apple.com/emea/support/itunes/contact.html

  • Low level events please URGENT

    hello
    please i have some problem with low level events.please anybody have some solution so please tell me
    basically any language such as c/c++ events are captured by operating system and then focusing on the particular component such as window or textbox etc.
    is there any bypass mechanism in java that we get the lovel level events from any operating system and all to do something.
    please Urgently reply me so that i can try for it, i have some work to do with this stuff.
    thanx in advance
    [email protected]

    You can already get mouse clicks, mouse motions, key presses... what other "low-level" events are you interested in?

  • HT1338 I have a macbook Pro i7 mid november 2010. I am wondering if i can exchange my notebook with the latest one. Can anyone help me out with this query please.

    I have a macbook Pro i7 mid november 2010. I am wondering if i can exchange my notebook with the latest one. Can anyone help me out with this query please.

    You can sell your existing computer using eBay, Craigslist or the venue of your choice. You could then use the proceeds to purchase a new computer.

  • TS1382 my ipod got wet and allow time to dry, I turn now the musics and sound and everything but the screen is blank and nothing is visible. a solution please urgent.

    my ipod got wet and allow time to dry, I turn now the musics and sound and everything but the screen is blank and nothing is visible. a solution please urgent.

    See my reply to your other post

  • I forgot my security question and i guess i failed all mt atempts, what can i do ? please urgently..

    Hello,
    i forgot my security question and i guess i failed all mt atempts, what can i do ? please urgently..

    You need to ask Apple to reset your security questions. To do this, click here and pick a method; if that page doesn't list one for your country or you're unable to call, fill out and submit this form.
    They wouldn't be security questions if they could be bypassed without Apple verifying your identity.
    (112725)

  • Row to column query ( Please its urgent)

    The query is
    SELECT
    WO.WORKORDERKEY,
    UDF1.PROJECT_MANAGER,
    UDF1.TEAM_MANAGER,
    UDF1.TEAM_LEAD,
    UDF1.CUSTOMER_COORDINATOR,
    UDF1.AVIONICS_LEAD,
    UDF1.INTERIOR_LEAD,
    UDF1.INSPECTOR,
    UDF1.MECHANICAL_ENGINEER,
    UDF1.AVIONICS_ENGINEER,
    UDF1.PLANNER,
    UDF1.PARTS_COORDINATOR,
    UDF1.LOGO_HEADER_SELECTION
    FROM
    WORKORDERS WO,
    SELECT
    DISTINCT WOUD.WORKORDERKEY,
    DECODE(UDF.LABEL,'Project Manager',SUBSTR(TO_CHAR(WOUD.DATA), 1, 50),NULL) AS PROJECT_MANAGER,
    DECODE(UDF.LABEL,'Team Manager',SUBSTR(TO_CHAR(WOUD.DATA), 1, 50),NULL) AS TEAM_MANAGER,
         DECODE(UDF.LABEL,'Team Lead',SUBSTR(TO_CHAR(WOUD.DATA), 1, 50),NULL) AS TEAM_LEAD,
    DECODE(UDF.LABEL,'Customer Coordinator',SUBSTR(TO_CHAR(WOUD.DATA), 1, 50),NULL) AS CUSTOMER_COORDINATOR,
    DECODE(UDF.LABEL,'Avionics Lead',SUBSTR(TO_CHAR(WOUD.DATA), 1, 50),NULL) AS AVIONICS_LEAD,
    DECODE(UDF.LABEL,'Interior Lead',SUBSTR(TO_CHAR(WOUD.DATA), 1, 50),NULL) AS INTERIOR_LEAD,
    DECODE(UDF.LABEL,'Inspector',SUBSTR(TO_CHAR(WOUD.DATA), 1, 50),NULL) AS INSPECTOR,
    DECODE(UDF.LABEL,'Mechanical Engineer',SUBSTR(TO_CHAR(WOUD.DATA), 1, 50),NULL) AS MECHANICAL_ENGINEER,
    DECODE(UDF.LABEL,'Avionics Engineer',SUBSTR(TO_CHAR(WOUD.DATA), 1, 50),NULL) AS AVIONICS_ENGINEER,
    DECODE(UDF.LABEL,'Planner',SUBSTR(TO_CHAR(WOUD.DATA), 1, 50),NULL) AS PLANNER,
    DECODE(UDF.LABEL,'Parts Coordinator',SUBSTR(TO_CHAR(WOUD.DATA), 1, 50),NULL) AS PARTS_COORDINATOR,
    DECODE(UDF.LABEL,'Report Logo/Header Selection',SUBSTR(TO_CHAR(WOUD.DATA), 1, 50),NULL) AS LOGO_HEADER_SELECTION
    FROM
    USERDEFINEDFIELDS UDF,
    WORKORDERUDFDATA WOUD
    WHERE
    UDF.USERDEFINEDFIELDKEY = WOUD.USERDEFINEDFIELDKEY
    AND UDF.LABEL IN('Project Manager','Team Manager','Team Lead','Customer Coordinator','Avionics Lead','Interior Lead','Inspector','Mechanical Engineer','Avionics Engineer','Planner','Parts Coordinator','Report Logo/Header Selection')
    AND UDF.DELETED = 0
    AND WOUD.DELETED = 0
    ) UDF1
    WHERE
    WO.WORKORDERKEY = UDF1.WORKORDERKEY(+);
    The output i am getting like:
    WORKORDERKEY     PROJECT_MANAGER     TEAM_MANAGER     TEAM_LEAD     CUSTOMER_COORDINATOR
    1     abc               
    2          ddf          
    2               rrr     
    3     aaf               
    3                    ege
    i need in single line work order key
    WORKORDERKEY     PROJECT_MANAGER     TEAM_MANAGER     TEAM_LEAD     CUSTOMER_COORDINATOR
    1     abc               
    2          ddf     rrr     
    3     aaf               ege
    Please solve my problem.

    maybe this example might be of some help.
    SQL> select * from pivot_tab;
          COL1 COL2
             1 a
             1 b
             1 c
             2 h
             2 h
    SQL>
    SQL>
    SQL> select p.col1,
      2         substr(max(substr(sys_connect_by_path (p.col2,','),2)),1,60)
      3         as col2
      4    from (select col1,
      5                 col2,
      6                 row_number() over (partition by col1 order by col1, col2) rn
      7            from pivot_tab) p
      8  start with p.rn = 1
      9  connect by p.rn = prior p.rn + 1
    10  and prior p.col1 = p.col1
    11  group by col1;
          COL1 COL2
             1 a,b,c
             2 h,h
    SQL>

  • Query  -  please help - Urgent

    Hi,
    Currently we have a query (Created on Multicube - one is sales plan cube and another is Sales actuals).
    When we run the query on a particular day (example: 7/10/2006), the report looks like as below:
    Cal.Year/Month       Sales plan     Sales Actuals
    Jan'06               310             305
    Feb'06               280             277
    Mar'06               310             309
    Apr'06               300             300
    MAy'06               310             305
    June'06              300             305
    July'06              310             90
    The current report shows the whole month's Sales Plan (July'06 - 310) with Actual Sales for 9 days(for July'06 - 90). Whereas, We want to compare the sales Plan (first 9 days of the month) against the sales actuals for 9 days.
    We do not have 0calday in both the cubes. Please help.
    Thanks,

    David,
    As rightly pointed out , you cannot get the plan value for 9 days if you do not have 0calday. However some things you can do...
    1. Have a virtual KF which gets the number of days from the current calendar day ( system date ) to the first date of the month - this can be written with a simple exit since the first date is fixed.
    2. calculate the plan value from that - pro rated plan value = plan value for month / number of days in month * number of days elapsed. If need be have the virtual KF return the ratio of number of days elapsed/number of days in the month
    3. Now you can do the comparison assuming that the value of actuals will be till the current date and not beyond.
    This is assuming that you can write a Virtual KF and the number of records is less enough to avoid any performance issues
    Hope it helps..
    Arun
    Assign points if helpful
    Message was edited by: Arun Varadarajan

  • Please find this query very urgent

    Query-->select value from mytable where value is not null
         union all
    select value from mytable where value is null
    Ex: table name::mytable
    In this table i have one column called 'value' and this column values shold be like this
    12
    null
    13
    null
    11
    null
    ....i executed above query the result will be like this
    12
    13
    11
    null
    null
    null
    the above query executes on the table it's effect only one column result
    but i need multiple columns to be effected same as above one only....Anyone please help me on it and give the query.

    I have a table..MyTable(value number(10))
    select * from Mytable;value
    12
    null
    13
    null
    11
    null
    This is the table i have and the records i have...... and i need output like this
    value
    12
    13
    11
    null
    null
    null ..............>ike this i need output for this i use this query i.e
    Query-->select value from mytable where value is not null
    union all
    select value from mytable where value is null
    ------------>and this query gives only one column result i need multiple results like below: i have table with 2 columns like below
    MyTable2(value1 number(10),value2 number(10))
    select * fromMyTable2value1 value2
    111 null
    null 201
    112 null
    null 200
    110 null
    this is the table i have......... and i need output like below
    value1 value2
    111 201
    112 200
    110 null
    null null
    null null
    NOTE:: If we use ORDER BY table records order must change, i don't want to change any order....please what is the query for that

Maybe you are looking for