IF IT IS FOUND, THEN SELECT ALL

/ * Formatted on 02/04/2015 15:38:23 (PS5 v5.139.911.3011) * /.

WITH t AS (SELECT '001' AS user_id, 'a' branch AS FROM DUAL

UNION ALL

SELECT '001' AS user_id, 'b' AS branch FROM DUAL

UNION ALL

SELECT user_id '001', 'c' AS branch OF DOUBLE),

q AS (SELECT 'a' AS a branch FROM DUAL)

UNION ALL

SELECT 'b' AS branch FROM DUAL

UNION ALL

SELECT 'c' AS branch FROM DUAL

UNION ALL

SELECT would be "AS branch FROM DUAL

UNION ALL

SELECT 'e' AS a branch FROM DUAL)

User ID given '001' then exit ' a ',' b ', 'c '.

If user id not in t, say '002' and then exit all branches ' has ',' b ' ' d 'c', ',' "e".

Thank you..

Best regards, ib

SQL> var user_id varchar2(10)
SQL>
SQL> exec :user_id := '001'

PL/SQL procedure successfully completed.

SQL> WITH t AS (SELECT '001' AS user_id, 'a' AS branch FROM DUAL
  2             UNION ALL
  3             SELECT '001' AS user_id, 'b' AS branch FROM DUAL
  4             UNION ALL
  5             SELECT '001' AS user_id, 'c' AS branch FROM DUAL),
  6       q AS (SELECT 'a' AS branch FROM DUAL
  7             UNION ALL
  8             SELECT 'b' AS branch FROM DUAL
  9             UNION ALL
 10             SELECT 'c' AS branch FROM DUAL
 11             UNION ALL
 12             SELECT 'd' AS branch FROM DUAL
 13             UNION ALL
 14             SELECT 'e' AS branch FROM DUAL)
 15  select branch
 16    from (
 17            select q.branch
 18                 , t.user_id
 19                 , count(t.user_id) over() cnt
 20              from t
 21              right join q
 22                on t.branch = q.branch
 23               and t.user_id = :user_id
 24         )
 25   where cnt = 0
 26      or (cnt > 0 and user_id is not null)
 27   order
 28      by branch;

B
-
a
b
c

SQL>  exec :user_id := '002'

PL/SQL procedure successfully completed.

SQL> WITH t AS (SELECT '001' AS user_id, 'a' AS branch FROM DUAL
  2             UNION ALL
  3             SELECT '001' AS user_id, 'b' AS branch FROM DUAL
  4             UNION ALL
  5             SELECT '001' AS user_id, 'c' AS branch FROM DUAL),
  6       q AS (SELECT 'a' AS branch FROM DUAL
  7             UNION ALL
  8             SELECT 'b' AS branch FROM DUAL
  9             UNION ALL
 10             SELECT 'c' AS branch FROM DUAL
 11             UNION ALL
 12             SELECT 'd' AS branch FROM DUAL
 13             UNION ALL
 14             SELECT 'e' AS branch FROM DUAL)
 15  select branch
 16    from (
 17            select q.branch
 18                 , t.user_id
 19                 , count(t.user_id) over() cnt
 20              from t
 21              right join q
 22                on t.branch = q.branch
 23               and t.user_id = :user_id
 24         )
 25   where cnt = 0
 26      or (cnt > 0 and user_id is not null)
 27   order
 28      by branch;

B
-
a
b
c
d
e

SQL>

Tags: Database

Similar Questions

  • you really need to set up a place to enter bugs.   When you select a page in the Panel of the browser, then select all, the program crashes.   Acrobat CC on el capitan mac.

    you really need to set up a place to enter bugs.   When you select a page in the Panel of the browser, then select all, the program crashes.   Acrobat CC on el capitan mac.

    Hi, Hello, Hello, Hello, bongiorno.

    ==> Feature request/Bug Report Form

    .

  • How we select all '? ' marked photos to remove from the catalog?

    I had to Remove the 1 x 1.  Then when the program crashed afterwards, and I opened it, I had to do it all over again.

    I don't want to Remove their disk yet.  Thank you

    Steve,

    Go to the library/grid, select "All photos" and choose library-> Find lack of Photos. This will show you all the photos in your catalog that was not found. Select all and press the delete key.

    Beat

  • How to select all the text with QNX TextInput

    With QNX TextInput, is there a way to select all the text? Spark TextInput a selectAll() method to select all text, but I do not see a similar method in QNX TextInput. No idea how you can choose all the texts with QNX TextInput. Thank you.

    Hey French,.

    Thanks for the clarification! I think I can help you. Here is a code example to show my explanation. In the code below when a user clicks the LabelButton object it will assign the focus to your TextInput object and then select all the text in this object. The only downside is that it will not bring the keyboard. so far, we are not successfully by invoking the keyboard without the user clicking on the TextInput. in any case in the code below, we use TextInput property the textField object as a reference to the TextField object internal. from there, we use the setSelection() method to select the text inside the object from the start to the end position pos. Here's the same code:

    package
    {
        import flash.display.Sprite;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;
        import flash.events.FocusEvent;
        import flash.events.MouseEvent;
    
        import qnx.ui.buttons.LabelButton;
        import qnx.ui.text.TextInput;
    
        [SWF(width="1024",height="600",backgroundColor="#CCCCCC",frameRate="30")]
        public class TextInputTest extends Sprite
        {
    
            private var myInput:TextInput;
    
            public function TextInputTest()
            {
                super();
    
                // support autoOrients
                stage.align = StageAlign.TOP_LEFT;
                stage.scaleMode = StageScaleMode.NO_SCALE;
    
                myInput = new TextInput();
                myInput.setSize(300,50);
    
                addChild(myInput);          
    
                var newBtn:LabelButton = new LabelButton();
                newBtn.label = "Click Me";
                newBtn.setPosition(325, 0);
    
                newBtn.addEventListener(MouseEvent.CLICK, selectMyText);
    
                addChild(newBtn);
    
            }
            private function selectMyText(e:MouseEvent):void
            {
                stage.focus = myInput;
                myInput.textField.setSelection(0, myInput.textField.length);
            }
        }
    }
    

    hope it's what you want. Good luck!

  • Select all the previous current Position Hotkeys?

    A few times I need to move large selections of audio and video. Rather than zoom, then select all, is there a key combination which will select everything to the right of my current position?

    I looked in the Adobe Help for access keys, but didn't see it.

    Thank you

    The a button replaces the tool select all.  It will select the entire document to the right on the same tracks.  Hold the SHIFT key and it will select the entire document to the right on all the tracks.

  • If the record not found this particular date, then select the last recordings date.

    I have three columns
    Number DP_FND_CODE;
    Date of DP_DATE;
    Number DPPRICE;

    I want that if dp_uprice not found this particular date (: dd1) then
    Select maximum Dp_uprice that the date would be less then: dd1

    Example: -.
    I run query and :DD1 parameter = 18/10/2010
    
    SELECT dp_fnd_code, dp_date , dp_uprice dpprice 
    FROM dailyprice where dp_date = :dd1
    
    DP_FND_CODE DP_DATE                      DPPRICE
    ----------- ----------------------- ------------
              1 18/10/2010                  109.0344
              2 18/10/2010                   10.1045
              3 18/10/2010                  100.4010
              4 18/10/2010                  102.3276
              6 18/10/2010                   14.6958
              7 18/10/2010                   98.8300
              8 18/10/2010                  102.0900
    It will show that all the Archives: dd1 = 18/10/2010, you can see above the result of the query DP_FND 5 is missing.
    I want to if there is no DPRICE of that particular date (: DD1) then it shows the date of the last DPPRICE.
    Like this
    DP_FND_CODE DP_DATE                      DPPRICE
    ----------- ----------------------- ------------
              1 18/10/2010                  109.0344
              2 18/10/2010                   10.1045
              3 18/10/2010                  100.4010
              4 18/10/2010                  102.3276
              5 16/10/2010                  122.3276          
              6 18/10/2010                   14.6958
              7 18/10/2010                   98.8300
              8 18/10/2010                  102.0900
    so I used this query, but correct nicely.
    SELECT dp_fnd_code, dp_date, 
                 case when dp_uprice is null then(
               select max(dp_uprice) dpprice from dailyprice where dp_date < :dd1 group by dp_fnd_code,dp_date
               ) else dp_uprice  end dpprice 
      FROM dailyprice 
      where dp_date = :dd1
      order by dp_fnd_code
      
    Thanks in advance.
    SELECT dp_fnd_code,
           max(dp_date) keep (dense_rank last order by dp_date),
           max(dpprice) keep (dense_rank last order by dp_date)
      FROM dailyprice
      where dp_date <= :dd1
      group by dp_fnd_code
      order by dp_fnd_code;
    
  • Garbage Vs all select all and then remove

    In mail, there is now an option in the trash all that is very useful.

    However, I keep the emails in my Inbox for any future reference. If I get new emails I want to the trash and use the option all rubbish, he trashes not only new emails, but also e-mails I saved. I guess that there is still no option to select all, then trash. Currently, I'm going to edit mode and manually select each email and then trash. All that I'm missing?

    Thank you.

    Shawn

    srmsrm wrote:

    In mail, there is now an option in the trash all that is very useful.

    However, I keep the emails in my Inbox for any future reference. If I get new emails I want to the trash and use the option all rubbish, he trashes not only new emails, but also e-mails I saved. I guess that there is still no option to select all, then trash. Currently, I'm going to edit mode and manually select each email and then trash. All that I'm missing?

    Thank you.

    Shawn

    Trash everything or select everything would be the same, it will remove all your e-mail.

    You will need to manually select the emails you want to remove, then emails you don't want deleted.

  • By selecting all the neutral/Greytones

    Hello

    I'm curious to know if anyone knows a clever way to select all neutral greytones in an image (my images have the colors and greytones). I have experimented with the color range, however I can't seem to narrow down the selection until I want to (not even close honestly). These are complex selections, and gray is inserted in the image. I can't image there is a way to do it, but I have not found anything online at the moment. Any help would be greatly appreciated!

    Thank you

    jpg

    EDIT: Oops, not a response to you Trevor, but to the op.

    I see that you deleted a response here, but here is your mask.

    The key is always Lab as csuebele suggested. Put a transparent layer in your image, then use the mixture if and assign a and b channels to 126-132. This gives you some share values, and on the other the neutral. Expand the blur values. Layer > Merge Visible.

    You have now your mask as opaque pixels and the rest to be transparent. Click on the thumbnail of the layer to load a selection and fill it black and white.

  • (CS3; JavaScript) how effectively "select all" / performing an action

    Hi all

    while I found little code to run applescript action I need to be able to do from JavaScript. The documentation does not mention at all of the shares.

    It would save me a lot of work if I could just perform an action that changes the color of the document to CMYK instead of having to duplicate all objects in a new document (I have already created the action and it works)

    This brings me to my other question: are there really no "select all"? It takes almost 2 seconds (at least if the Profiler is right) just to select a simple 300 objects in my test file. I need to batch process something like 30 records that could prove more complex and I don't like the idea to say to my colleagues that they should wait for so long...

    Is there a better way that a loop through pageItems and setting .selected = true?

    I could imagine performs an action that selects all objects (how to copy actions to others machines. btw?) or to run the shortcut (Ctrl + a).

    Thank you very much

    Mike

    Good evening

    Void test_ai()

    Set myAi = CreateObject ("illustrator.application.CS4")
    Set myDocAi = myAi.ActiveDocument

    ' - An idea is to show, as a first step, the layers on which you want to select all objects.

    myDocAi.Layers ("myLayerWithObjects"). Visible = True
    myDocAi.ActiveLayer.Locked = False

    myDocAi.Layers ("mySecondLayerWithObjects"). Visible = True
    myDocAi.ActiveLayer.Locked = False

    ' - In a second step, you select all

    For each myLayers in myDocAi.Layers
    If myLayers.Visible = True Then myLayers.HasSelectedArtwork = True
    Next

    ' - and finally, you define a variable with your selection

    myselexion = myAi.Selection

    End Sub

    After that, you will probably identify each item of your choice.

    Best regards

    Patrice

  • No data found in SELECT INTO

    Hi all

    I try to choose in a variable in a loop of cursor but I get NO DATA FOUND when
    Select does not return a value.
    I want to set the variable to 0 when the selection fails.

    I tried to add an exception, but I get the following:

    ORA-00900: invalid SQL statement


    Here is the code I am trying to run (the exception is commented):

    Line: -.
    PROCEDURE MyProc IS
    v_op NUMBER;
    BEGIN

    FOR cursor1 IN (select * from myTable)
    LOOP
    Operation of SELECTION IN v_op from operationsTable where id = cursor1.ID;


    -EXCEPTION *.
    -WHEN NO_DATA_FOUND THEN
    -v_op: = 0;

    -END; *

    END LOOP;
    MyProc END;
    Line: -.

    Does anyone know how to set a variable when the selection fails and NO DATA FOUND?
    Thank you
    dyahav

    You need to hold your exception by BEGIN and END

    BEGIN
    
    select into...
    
    EXCEPTION WHEN NO_DATA_FOUND
    do_something
    END;
    
  • Select all the messages and support those want to register without selecting him coming all out

    Another email I was able to select all and then click ones I wanted there without taking off select them highlighted. If I do this with Mozilla, we highlight the rest. I have over 3,000 and the need to delete without having to move the others I want to left. How can I do this?

    CTRL + A = select ALL.
    Shift + click = Select all between clicks.
    CTRL preserves the State and allows clicking on selected to deselect and vice versa.

  • I'm trying implement highlight/select all mails from a particular sender to remove

    My Inbox needs serious editing. A lot of unwanted emails. I would like to delete e-mails in groups, but do not know how to select or highlight an entire group, which can then be removed.

    You can click on any column heading to sort by that column. Clicking the same header again reverses the sort.
    Then you use basic computer skills to select multiple items
    Click the point 1. Up or down several elements and hold down the SHIFT key when you click on the point 2. This allows to select the elements 1 and 2 and everything in between.
    Holding down the CTRL key and clicking on random element will select all clicked on element.
    Select an item. Press Ctrl + a to select.
    Hold down the CTRL key when you click on a selected item to deselect the item.

  • in firefox 3,604 rather than the set up functions are available except for select all, why?

    Hallo all

    I am using Fireefox 3.6 04 on a win7 64byte laptop.
    

    I would like to organize some of my favorites into folders, but 'organize' options are all greyed out except "select all" and "copy".
    Does anyone have any ideas why this would be. The only references I've found so far relate to Apple operating systems
    and I thought that for once, I was really going to organize! Any ideas appreciated with thanks and Happy Easter to everyone anyway.

    You can only hold individual folders and bookmarks and not three folder root which show in the screenshot.
    You must open one of the folders to move bookmarks in this folder to another folder.

    There are three main folders of bookmarks and bookmarks can be created only in one of these folders and its subfolders.

    • The folder "Personal bar" stores the bookmarks that you see in the bookmarks toolbar (Firefox > Options or view > toolbars).
    • "Bookmarks Menu" file stores the bookmarks that display in the bookmarks menu and are created through ' bookmarks > bookmark this Page "or" bookmark this link "in the context menu.
    • The "Unsorted Bookmarks" folder stores created bookmarks by clicking on the star on the right end of the address bar.
  • Select all (CTRL + A) does not select messages

    Thunderbird 31.3.0
    Windows 7 Pro 64 - bit, English
    Swedish locale

    By pressing the shortcut CTRL + A or by using the menu option "Edition > select > all ' only selects all messages.

    A custom button 'select all' created to https://codefisher.org/toolbar_button/toolbar_button_maker end works as a workaround.

    Anyone encountered this problem and knows a solution?

    Best regards
    Johan

    After working with someone who had found that the search function was located to ctrl + T instead of ctrl + F, I would suggest that you install also the keyconfig extension so you can see what strikes it's supposed to be to aid. Maybe some overzealous location it has mapped to another key?

    http://KB.mozillazine.org/Keyconfig_extension

    However, I do not think that this would explain the menu editing > select > all the does not.

    It works better or differently in Safe Mode?

    https://support.Mozilla.org/en-us/KB/safe-mode

  • I can't "Select all" in any category, such as 'Trash' or 'Sent' to remove any.

    I can find is no longer a "select all", nor can I scroll to select items in the 'Trash' or 'Sent' to remove them.

    RE: Trash:
    You don't need to 'select all', you right-click on the trash folder and select "empty trash".

    RE: Send the file:
    Select the first email, then press "Ctrl" + "A" key to highlight all emails.
    They will appear in the stream of messages as conversations.
    Click on the button 'delete '.
    This will remove all the emails highlighted.
    then right click on the "Sent" folder and select "Compact" to remove all traces of emails "marked as deleted.

Maybe you are looking for