How do I correct this query ?

here is a query:
select roleid from Apps_USERROLE where guid in (select guid from Apps_USER_MASTER order by userid)
This does not work ...because the internal subquery retruns multiple result.
How do I correct this query ?

Satish Kandi wrote:
select roleid from Apps_USERROLE where guid in (select guid from Apps_USER_MASTER order by userid)ORDER BY clause is not supported in subqueries since it makes no sense.
If you want an ordered result set, you need add order by clause to the main query.
select roleid from Apps_USERROLE where guid in (select guid from Apps_USER_MASTER)
order by roleid;
HTH...we have a problem then . Apps_USER_MASTER has userid as primary key .
select guid from Apps_USER_MASTER => this could give duplicate guid then .

Similar Messages

  • How I can change this query, so I can display the name and scores in one r

    How I can change this query, so I can add the ID from the table SPRIDEN
    as of now is giving me what I want:
    1,543     A05     24     A01     24     BAC     24     BAE     24     A02     20     BAM     20in one line but I would like to add the id and name that are stored in the table SPRIDEN
    SELECT sortest_pidm,
           max(decode(rn,1,sortest_tesc_code)) tesc_code1,
           max(decode(rn,1,score)) score1,
           max(decode(rn,2,sortest_tesc_code)) tesc_code2,
           max(decode(rn,2,score)) score2,
           max(decode(rn,3,sortest_tesc_code)) tesc_code3,
           max(decode(rn,3,score))  score3,
           max(decode(rn,4,sortest_tesc_code)) tesc_code4,
           max(decode(rn,4,score))  score4,
           max(decode(rn,5,sortest_tesc_code)) tesc_code5,
           max(decode(rn,5,score))  score5,
           max(decode(rn,6,sortest_tesc_code)) tesc_code6,
           max(decode(rn,6,score))  score6        
      FROM (select sortest_pidm,
                   sortest_tesc_code,
                   score,
                  row_number() over (partition by sortest_pidm order by score desc) rn
              FROM (select sortest_pidm,
                           sortest_tesc_code,
                           max(sortest_test_score) score
                      from sortest,SPRIDEN
                      where
                      SPRIDEN_pidm =SORTEST_PIDM
                    AND   sortest_tesc_code in ('A01','BAE','A02','BAM','A05','BAC')
                     and  sortest_pidm is not null 
                    GROUP BY sortest_pidm, sortest_tesc_code))
                    GROUP BY sortest_pidm;
                   

    Hi,
    That depends on whether spriden_pidm is unique, and on what you want for results.
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevamnt columns only) for all tables, and the results you want from that data.
    If you can illustrate your problem using commonly available tables (such as those in the scott or hr schemas) then you don't have to post any sample data; just post the results you want.
    Either way, explain how you get those results from that data.
    Always say which version of Oracle you're using.
    It looks like you're doing something similiar to the following.
    Using the emp and dept tables in the scott schema, produce one row of output per department showing the highest salary in each job, for a given set of jobs:
    DEPTNO DNAME          LOC           JOB_1   SAL_1 JOB_2   SAL_2 JOB_3   SAL_3
        20 RESEARCH       DALLAS        ANALYST  3000 MANAGER  2975 CLERK    1100
        10 ACCOUNTING     NEW YORK      MANAGER  2450 CLERK    1300
        30 SALES          CHICAGO       MANAGER  2850 CLERK     950On each row, the jobs are listed in order by the highest salary.
    This seems to be analagous to what you're doing. The roles played by sortest_pidm, sortest_tesc_code and sortest_test_score in your sortest table are played by deptno, job and sal in the emp table. The roles played by spriden_pidm, id and name in your spriden table are played by deptno, dname and loc in the dept table.
    It sounds like you already have something like the query below, that produces the correct output, except that it does not include the dname and loc columns from the dept table.
    SELECT    deptno
    ,       MAX (DECODE (rn, 1, job))     AS job_1
    ,       MAX (DECODE (rn, 1, max_sal))     AS sal_1
    ,       MAX (DECODE (rn, 2, job))     AS job_2
    ,       MAX (DECODE (rn, 2, max_sal))     AS sal_2
    ,       MAX (DECODE (rn, 3, job))     AS job_3
    ,       MAX (DECODE (rn, 3, max_sal))     AS sal_3
    FROM       (
               SELECT    deptno
               ,          job
               ,          max_sal
               ,          ROW_NUMBER () OVER ( PARTITION BY  deptno
                                              ORDER BY          max_sal     DESC
                                )         AS rn
               FROM     (
                             SELECT    e.deptno
                       ,           e.job
                       ,           MAX (e.sal)     AS max_sal
                       FROM      scott.emp        e
                       ,           scott.dept   d
                       WHERE     e.deptno        = d.deptno
                       AND           e.job        IN ('ANALYST', 'CLERK', 'MANAGER')
                       GROUP BY  e.deptno
                       ,           e.job
    GROUP BY  deptno
    ;Since dept.deptno is unique, there will only be one dname and one loc for each deptno, so we can change the query by replacing "deptno" with "deptno, dname, loc" throughout the query (except in the join condition, of course):
    SELECT    deptno, dname, loc                    -- Changed
    ,       MAX (DECODE (rn, 1, job))     AS job_1
    ,       MAX (DECODE (rn, 1, max_sal))     AS sal_1
    ,       MAX (DECODE (rn, 2, job))     AS job_2
    ,       MAX (DECODE (rn, 2, max_sal))     AS sal_2
    ,       MAX (DECODE (rn, 3, job))     AS job_3
    ,       MAX (DECODE (rn, 3, max_sal))     AS sal_3
    FROM       (
               SELECT    deptno, dname, loc          -- Changed
               ,          job
               ,          max_sal
               ,          ROW_NUMBER () OVER ( PARTITION BY  deptno      -- , dname, loc     -- Changed
                                              ORDER BY          max_sal      DESC
                                )         AS rn
               FROM     (
                             SELECT    e.deptno, d.dname, d.loc                    -- Changed
                       ,           e.job
                       ,           MAX (e.sal)     AS max_sal
                       FROM      scott.emp        e
                       ,           scott.dept   d
                       WHERE     e.deptno        = d.deptno
                       AND           e.job        IN ('ANALYST', 'CLERK', 'MANAGER')
                       GROUP BY  e.deptno, d.dname, d.loc                    -- Changed
                       ,           e.job
    GROUP BY  deptno, dname, loc                    -- Changed
    ;Actually, you can keep using just deptno in the analytic PARTITION BY clause. It might be a little more efficient to just use deptno, like I did above, but it won't change the results if you use all 3, if there is only 1 danme and 1 loc per deptno.
    By the way, you don't need so many sub-queries. You're using the inner sub-query to compute the MAX, and the outer sub-query to compute rn. Analytic functions are computed after aggregate fucntions, so you can do both in the same sub-query like this:
    SELECT    deptno, dname, loc
    ,       MAX (DECODE (rn, 1, job))     AS job_1
    ,       MAX (DECODE (rn, 1, max_sal))     AS sal_1
    ,       MAX (DECODE (rn, 2, job))     AS job_2
    ,       MAX (DECODE (rn, 2, max_sal))     AS sal_2
    ,       MAX (DECODE (rn, 3, job))     AS job_3
    ,       MAX (DECODE (rn, 3, max_sal))     AS sal_3
    FROM       (
                   SELECT    e.deptno, d.dname, d.loc
              ,       e.job
              ,       MAX (e.sal)     AS max_sal
              ,       ROW_NUMBER () OVER ( PARTITION BY  e.deptno
                                           ORDER BY       MAX (sal)     DESC
                                          )       AS rn
              FROM      scott.emp    e
              ,       scott.dept   d
              WHERE     e.deptno        = d.deptno
              AND       e.job                IN ('ANALYST', 'CLERK', 'MANAGER')
                  GROUP BY  e.deptno, d.dname, d.loc
              ,       e.job
    GROUP BY  deptno, dname, loc
    ;This will work in Oracle 8.1 and up. In Oracle 11, however, it's better to use the SELECT ... PIVOT feature.

  • How can i improve this query.

    Hi guys i am beginner , just wanted to know some info , how can i improve this query ..
    select *
    from tableA A, viewB B,
    where A.key = B.key
    and a.criteria1 = '111'
    and a.criteria2 = some_funtion(a.key)
    one more thing should function should be on left side of equal sign.
    will a join make it better or something else is needed more than that .

    952936 wrote:
    Hi guys i am beginner , just wanted to know some info , how can i improve this query ..
    select *
    from tableA A, viewB B,
    where A.key = B.key
    and a.criteria1 = '111'
    and a.criteria2 = some_funtion(a.key)
    one more thing should function should be on left side of equal sign.
    will a join make it better or something else is needed more than that .If you are a beginner try to learn the ANSI Syntax. This will help you a lot to write better queries.
    Your select would look like this in ANSI.
    select *
    from tableA A
    JOIN viewB B ON A.key = B.key
    WHERE a.criteria1 = '111'
    and a.criteria2 = some_function(a.key);The good thing here is that this separates the typical joining part of the select from the typical filter criteria.
    The other syntax very often let you forget one join. Just because there are so many tables and so many filters, that you just don't notice correctly anymore what was join and what not.
    If you notice that the number of column is not what you expect, you can easiely modify the query and compare the results.
    example A
    Remove View B from the query (temporarily comment it out).
    select *
    from tableA A
    --JOIN viewB B ON A.key = B.key
    WHERE a.criteria1 = '111'
    and a.criteria2 = some_funtion(a.key)
    example B
    You notice, that values from A are missing. Maybe because there is no matching key in ViewB? Then change the join to an outer join.
    select *
    from tableA A
    LEFT OUTER JOIN viewB B ON A.key = B.key
    WHERE a.criteria1 = '111'
    and a.criteria2 = some_funtion(a.key)(The outer keyword is optional, left join would be enough).

  • TA24326 My HP desktop running Windows Vista 32-bit no longer recognizes my iPhone 4 when I connect it. How do I correct this?

    My HP desktop running Windows Vista 32-bit no longer recognizes my iPhone 4 when I connect it. How do I correct this?

    Device not recognized in iTunes

  • When trying to udate iTunes on my PC, I recieve the error message "The older version of iTunes cannot be removed"  How do I correct this error and not lose all the music I have in iTunes?

    When trying to update my version of iTunes on my PC with Windows 7,  I receive the error message "The older version of iTunes cannot be romoved".  How do I correct this problem without losing all the music that I have in iTunes on my PC?

    (1) Download the Windows Installer CleanUp utility installer file (msicuu2.exe) from the following Major Geeks page (use one of the links under the thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    (2) Doubleclick the msicuu2.exe file and follow the prompts to install the Windows Installer CleanUp utility. (If you're on a Windows Vista or Windows 7 system and you get a Code 800A0046 error message when doubleclicking the msicuu2.exe file, try instead right-clicking on the msicuu2.exe file and selecting "Run as administrator".)
    (3) In your Start menu click All Programs and then click Windows Install Clean Up. The Windows Installer CleanUp utility window appears, listing software that is currently installed on your computer.
    (4) In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove", as per the following screenshot:
    (5) Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?

  • HT5625 My daughter and I were both on same Apple ID. We are trying to change hers but when we do, it says her email is already associated with an Apple ID but when we try to get the password, it says that it could not be verified. How do we correct this?

    My daughter and I were both on same Apple ID. We are trying to change hers but when we do, it says her email is already associated with an Apple ID but when we try to get the password, it says that it could not be verified. How do we correct this?

    Not from your end. Click here and ask the iTunes Store staff for assistance.
    (126716)

  • My iPad does not have sound when on the Internet, including YouTube, but does have sound with iTunes and other apps.  How can I correct this?

    My iPad does not have sound when on the Internet, including YouTube, but does have sound with iTunes and other apps.  How can I correct this?

    If you are sure that you have sound in other apps - and if you can still hear keyboard clicks and get notifications, then system sounds are not muted. Try this and see if it works.
    Close all apps completely and reboot the iPad.
    Go to the home screen first by tapping the home button. Double tap the home button and the recents tray will appear with all of your recent apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the app that you want to close. Tap the home button or anywhere above the task bar.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • When I download a CD to iTunes, some CD's appear as separate albums. How can I correct this?

    When I download a CD to iTunes, some CD's appear as separate albums. How can I correct this?
    for some reason iTunes appears to believe some tracts are from a separate album. For instance, one recently released Rod Stewart CD HAS 8 tracts on one album and the remaining two tracts on two separate albums, all albums are called the correct album name?

    If your CD has tracks with different artists, or if there are differences in how the artist field is filled in for the different tracks, then you can fix this by identifying the disc as a 'compilation' CD.
    Select all of the tracks in the CD, then 'get info' (control-I), and go to 'Options'. Select 'yes' for 'Part of a compilation'. That should fix the problem.

  • My husband and I both have an i phone. When I send him a message it sends the message to myself as well - the same happens when he sends to me. How can we correct this?

    My husband and I both have an i phone. When I send him a message it also sends it back to my phone. The same happens when he messages me. His messages are also picked up on my i pad.How can we correct this?

    Are you both using the same Apple ID?
    Also check Settings > Messages > Send & Receive > make sure it only contains your unique phone number and e-mail address de-select those entries belonging to your husband.
    Do the same on his phone (de-select yours)

  • My itunes account information is correct.  when i try to make a purchase using my ipod touch, the wrong account shows up. how do i correct this?

    My itunes account information is correct.  However, when I try to make a purchase using my ipod touch, the old account name shows up.  How do I correct this?

    Launch iTunes on your computer.
    From the menu bar click Store / View My Account
    Click the Edit button next to:  Edit Payment Information
    You can edit your billing information there.

  • SINCE INSTALLING I.E. 11 IN WINDOWS 7, UNABLE TO DOWNLOAD OR SAVE FILES IN FIREFOX; HOW DO I CORRECT THIS PROBLEM?

    This is what I wrote to the Microsoft Community seeking a correction of the issue (still no reply to my request for assistance with this matter from them):
    Can I go back to I.E. 10? Ever since I installed version 11, I've had an unstable desktop. It appears to have damaged the Windows Explorer interface in other browsers, such that when I open the popup window to save downloads and/or other files, all that shows up in the window are the "Save" and "Cancel" buttons, but it does not show the interface to choose where to save the file(s), thus I cannot save anything at all in those other browsers. I primarily use Firefox, and every time I want to save a file, I have to startup I.E. 11 to save anything and everything.
    I would much prefer going back to I.E. 10 which caused me no such problems; but, if I cannot go back to I.E. 10, how do I correct this issue so I can save files in other browsers? This situation has been going on for months now, and I've waited patiently thinking that there would be an update for Microsoft and/or Firefox (as well as Chrome and Safari) that would correct this problem by now; but, even though I have all of the latest updates and versions installed, no updates have corrected the issue at all. I would very much appreciate any help you can give.
    Oh, also, I have tried uninstalling Firefox completely at least twice, and rebooting before reinstalling it to the latest version, but that has not corrected the problem either. I additionally tried turning I.E. 11 off in Windows, and then tried running Firefox to see if the download interface would be restored, but it still had the very same issue(s) [no ability to choose the place to save files, and thus being completely unable to save any downloads and/or other files]. I can't believe that this problem has been going on for so long now without any update(s) resolution.

    The following is the latest that I've written to Microsoft about this entire matter:
    You're still not getting it. I've never had a problem with downloading and/or saving files in I.E.; and I very clearly explained to you guys that the problem is in the other browsers, but it's caused by a malfunction in the Windows Desktop.
    Why can't someone with English as their first language, please help me?
    But, regardless, just in case your recommendation(s) had anything to do with anything, and were perhaps creating the problem in the other browser (though I was pretty sure that it had nothing to do with my problem), I made I.E. the default browser; yet, of course, that did NOT correct the problem. Also, when I set I.E. as the default browser, the explorer.exe file crashed and restarted.
    Nevertheless, because I (wrongly) thought that I couldn't uninstall I.E. 11, because somehow I missed the listing for it in Windows Programs and Features, I went to the latter again and found I.E. 11 listed this time, and uninstalled it. After it completed, I rebooted the laptop. Then I went into Windows Update and looked for what version of I.E. it was then going to want me to update to since I.E. 11 was uninstalled.
    I saw that I.E. was taken all the way back to I.E. 8 and had updates for it as well as to update to I.E. 9, so I did the former updates first, rebooted, then updated to I.E. 9 and rebooted again. Then I ran Windows Update again checking for new updates, and found that there was a cumulative security update for I.E. 9, which I installed and then rebooted once again.
    Then, upon checking for new updates in Windows Update again, I found that the option(s) to update to I.E. 10 or 11 were now optional, which they weren't before, and then I updated to I.E. 10 and rebooted once more. Upon Windows restarting, I checked again for new Windows Updates and there were some security updates, so I installed them and restarted the laptop.
    This time upon rebooting, I checked Windows Update for further new updates and there were none; so I'm now completely updated to I.E. 10; but, because going back to I.E. 10 corrected some of the instability with the Windows Desktop, I am ignoring the optional update to I.E. 11, and I am NOT going to update to it again.
    Throughout the update process, upon restarting Windows, I kept starting Firefox to see if the "Save As" window then worked, but throughout the entire update process, as well as when I completed it, I still could not download or save files [because the window still doesn't show where to save the file(s)---please see the Print Screen copy of what it looks like, attached to this message (sorry, but I.E. won't let me browse for the file, and the tab or windows crashes and reloads every time when I click "Browse" to look for the file to attach)].
    So, I decided to try uninstalling Firefox for the fourth time, rebooting and reinstalling it, hoping that might correct he issue this time since I downgraded to I.E. 10, but the "Save As" window still looks the same, and I am still completely unable to save any files or downloads while in Firefox.
    Oh, I also tried resetting all of the Windows Folder Options again to default settings, and reset all of the folders, in case that had anything to do with the problem, but that still did NOT correct the issue either.
    I am now going to try creating a new user account also with Administrator privileges, changing Users, trying to run Firefox in it, and see if the problem with the "Save As" window is still an issue....
    In the new User profile, the situation is even worse. When I try to save any file(s) in Firefox, Firefox crashes (latest version).
    I wrote to Firefox a couple of days ago, but an arrogant "techie" is giving me the run around and is not helping me, and no else is helping with the matter so far.
    Postscript: Now Windows Explorer (the explorer.exe file) that runs the desktop crashed and restarted again twice while I was trying to print a file, and it appears that it won't let me print at all anymore.

  • I keep getting an error message that reads: There is a problems with this windows installer package A program required for this install to complete could not be run. Contact your support personnel or package vendor. How do I correct this problem.

    I keep getting an error message that reads: There is a problems with this windows installer package A program required for this install to complete could not be run. Contact your support personnel or package vendor. How do I correct this problem. HELP !!!!!!!!!!!!!!

    Try the following user tip:
    "There is a problem with this Windows Installer package ..." error messages when installing iTunes for Windows

  • I no longer have sound when playing my clips through adobe premiere elements 12. How to I correct this problem? I have checked all audio levels and there is no mute on etc. I have updated to 12.1. Still no sound.

    I no longer have sound when playing my clips through adobe premiere elements 12. How to I correct this problem? I have checked all audio levels and there is no mute on etc. I updated to 12.1, but still no sound in any clips. Even not on old files which used to work.

    bfun
    What computer operating system is your Premiere Elements 12/12.1 running on? Can we assume that this audio plays back OK
    on the same computer when you are using a computer player independent of Premiere Elements?
    What are the properties of these clips that worked before but do not know with regard to sound
    For now, I will assume that you are working on Windows 7, 8, or 8.1 64 bit.
    Have you checked the Edit Menu/Preferences/Audio Hardware ASIO settings? Do you have any 3rd party audio devices incorporated in your computer environment?
    Please delete the Adobe Premiere Elements Prefs file and, if that does not work, then the whole 12.0 Folder in which the Adobe Premiere Elements Prefs file exists. The Windows 7, 8, or 8.1 64 bit path is
    Local Disk C
    Users
    Owner
    AppData
    Roaming
    Adobe
    Premiere Elements
    12.0
    and, in the 12.0 Folder, is the Adobe Premiere Elements Prefs file that you delete. If that does not work, then delete the whole 12.0 Folder in which the Adobe Premiere Elements Prefs file exists. Make sure that you are working with Folder Option "Show Hidden Files, Folders, and Drives" active so that you can see the complete path cited.
    Do you have installation files or installation disc with the purchased serial number in case we need to resort to uninstall/reinstall?
    We will be watching for your follow up.
    ATR

  • My gps is not working.  I cannot use turn-by-turn navigation in google maps.  I downloaded a GPS test app and it showed my phone is not locking on any satellites.  How can I correct this?

    My gps is not working.  I cannot use turn-by-turn navigation in google maps.  I downloaded a GPS test app and it showed my phone is not locking on any satellites.  How can I correct this?

    We certainly want to make sure you get the most out of the GPS, wplaxico! Was this tested primarily outdoors? When did this begin? Any other recent apps of updates installed when this started?
    Thank you,
    YaleK_VZW
    Follow us on Twitter @VZWSupport
    If my response answered your question please click the �Correct Answer� button under my response. This ensures others can benefit from our conversation. Thanks in advance for your help with this!!

  • HT3275 Time Machine Error: The backup disk image "Volumes/Data/My Macbook Pro.sparsebundle" is already in use. (How do I correct this issue?)

    Time Machine did not back up:
    Time Machine Error; ("The backup disk image "/Volumes/Data/My MacBook Pro.sparsebundle" is already in use.")
    How do I correct this issue?
    Thanks!

    You need to be careful Bob.. people might take this literally.
    Bob Timmons wrote:
    How do I correct this issue?
    Call the exterminator to get rid of the bugs in Lion and Mountain Lion.
    https://discussions.apple.com/thread/5222487?tstart=0

Maybe you are looking for

  • Bridge will not open

    I just re-installed CC apps on a new hard drive.  All seem to be starting fine except for Bridge.  When I start Bridge I get an error that says "The Operation Could Not Be Competed"  I am paying 50 freaking dollars a month for this stuff.  I expect i

  • Pricing table for Material pricing Group

    Hi everyone I have a problem related to pricing. In ECC, if we create a condition table for material pricing group, assign it to the Access sequence PR00 and then download the customizing data to CRM, the access sequence appears in CRM but without th

  • ACE - sticky serverfarm and sorry servers

    Primary serverfarm with stickiness (cookie insert) goes down. Backup serverfarm kicks in with sorry servers. Primary serverfarm comes back up and returning connections still get serviced by the backup farm. The reason for this is explained in the loa

  • First line from serial port, partial or junk data

    I'm trying to receive the following protocol which works, except I have to insert the equipment while the serial port is sending data.  So sometimes the first line is partial data and that causes errors down the line.    My thought was to wait to rec

  • Losing wi-fi while using IPTV

    Hi all, I've searched for this to no avail. I hope this isn't a common issue and I've just searched the wrong keywords. If so, I apologize. I am currently running a Motorola VIP1200 HD IPTV box through my Apple Airport Extreme 802.11n (7.4.2) router.