According to the value data display

Hi everyone, I need help to write a query. I have the following data:
WITH data1 AS
(
  SELECT 1 num,     'PAL1' acct     ,'PRIN' descr FROM dual UNION all
  SELECT 1 num,     'COL' acct     ,'SEC' descr FROM dual UNION ALL
  SELECT 1 num,     'COL' acct     ,'AL' descr FROM  dual UNION all

  SELECT 2 num,     'PAL2' acct     ,'PRIN' descr FROM dual UNION all
  SELECT 2 num,     'COL' acct     ,'SEC' descr FROM  dual UNION ALL
  SELECT 2 num,     'COL' acct     ,'AL' descr FROM  dual UNION all

  SELECT 3 num,     'PAL1' acct     ,'PRIN' descr FROM  dual UNION all
  SELECT 3 num,     'COL' acct     ,'SEC' descr FROM dual UNION ALL
  SELECT 3 num,     'COL' acct     ,'AL' descr FROM dual UNION all

  SELECT 4 num,     'COL' acct     ,'SEC' descr FROM dual UNION all
  SELECT 4 num,     'COL' acct     ,'SEC' descr FROM dual UNION ALL
  SELECT 4 num,     'MT' acct     ,'MA' descr FROM dual

)
The query that I write will be inside a PROCEDURE. a parameter will pass with the value of the ACTC.
the possible values of the parameter are: ALL, COL PAL1, PAL2, MT

If one value other than EVERYTHING happened inside I want to get all the lines for a specific number which contain at least one MAIN line.
for example
PAL1 pass, THEN the output should be
num    acct    descr
====   =====   ======
1      PAL1    PRIN
1      COL     SEC
1      COL     AL

3      PAL1    PRIN
3      COLL    SEC
3      COLL    AL
as you can see, the acct PAL1 contain at least one row with MAIN descr num = 1 and num = 3. in this case, all the lines for these num (ex num = 1 and 3)
have been exposed in the output.


Another example is that pal2 is pass, then output should be
num    acct    descr
====   =====   ======
2      PAL2    PRIN
2      COL     SEC
2      COL     AL
num = 2 in this case is the only one who has PAL2 and at least a main line.

now, let's say MT's past as a parameter, in this case num = 4 is the only one with a row of MT, but there is no MAIN line for this name.
so no output.

If the 'ALL' value is pass as a parameter, and then get all lines without worrying if a MAIN line closes. in this case the output should be
num    acct    descr
====   =====   ======
1      PAL1    PRIN
1      COL     SEC
1      COL     AL

2      PAL2    PRIN
2      COL     SEC
2      COL     AL

3      PAL1    PRIN
3      COLL    SEC
3      COLL    AL


4      COLL    SEC
4      COLL    SEC
4      MT      MA
and for the last example, if the PASS is a pass and then output should be
num    acct    descr
====   =====   ======
1      PAL1    PRIN
1      COL     SEC
1      COL     AL

2      PAL2    PRIN
2      COL     SEC
2      COL     AL

3      PAL1    PRIN
3      COLL    SEC
3      COLL    AL
as a MAIN line to num = 1, 2, 3 for VAC = PASS then all belonging to num lines specific should be display


can someone help me WRITE a query FOR this scenario?
Thank you. your help is appreciated

This will do

WITH data1 AS
(
  SELECT 1 num,     'PAL1' acct     ,'PRIN' descr FROM dual UNION all
  SELECT 1 num,     'COL' acct     ,'SEC' descr FROM dual UNION ALL
  SELECT 1 num,     'COL' acct     ,'AL' descr FROM  dual UNION all

  SELECT 2 num,     'PAL2' acct     ,'PRIN' descr FROM dual UNION all
  SELECT 2 num,     'COL' acct     ,'SEC' descr FROM  dual UNION ALL
  SELECT 2 num,     'COL' acct     ,'AL' descr FROM  dual UNION all

  SELECT 3 num,     'PAL1' acct     ,'PRIN' descr FROM  dual UNION all
  SELECT 3 num,     'COL' acct     ,'SEC' descr FROM dual UNION ALL
  SELECT 3 num,     'COL' acct     ,'AL' descr FROM dual UNION all

  SELECT 4 num,     'COL' acct     ,'SEC' descr FROM dual UNION all
  SELECT 4 num,     'COL' acct     ,'SEC' descr FROM dual UNION ALL
  SELECT 4 num,     'MT' acct     ,'MA' descr FROM dual

) select * from data1
where :param='ALL' or
(
  num in (select num from data1
    where acct=:param
    and exists(select 1 from data1 where acct=:param and descr='PRIN'))
)

Edit: replace: with param .parameter_name if necessary.

Published by: david.sweet on February 19, 2011 07:57

Published by: david.sweet on February 19, 2011 07:57

Tags: Database

Similar Questions

  • How to automatically complete a transitional according to the value of another attribute when attribute line is questioned in the VO?

    Hello world

    The task seems simple enough, but I have not found a way to populate an attribute transitional according to the value of another attribute when the line is queried. What is the best way to achieve this?

    Thank you.

    James

    Use VORowImpl, if you have any transient attributes defined in the view object, whose value is derived from other attributes of the line, you can override the GET method and add logic there

    Please note that this class represents a row in the results collection in a display object.

  • Clear the check box according to the value of column DB

    Hello
    My requirement is to disable the check box according to the value of a column DB. Say for example my report displays the following. Check box, the name of the EMP, Dept. If the Department is the checkbox should be disabled and user should not be able to select the check box.
    Ask your help for a solution.
    Thank you
    Prasanth

    You must use the parameter p_attributes of the apex_item.checkbox API to make the boxes off (readonly do not work with the checkboxes)

    SELECT ..
    CASE WHEN  THEN APEX_ITEM.CHECKBOX(1,)
                         ELSE APEX_ITEM.CHECKBOX(1,,'disabled="disabled"')
              END 
      ..
    
  • Image display according to the value selected from the bean of choice

    Hello

    I have a table with columns of bean of choice and have an another bean image

    based on the value selected from the bean of choice of a particular line, I want to display an image in the column of bean image

    and it is particularly in the line, in which the user changes the value of the bean of choice.

    Please help me

    Thank you

    Hello
    H1.

    If I choose 'user' of choice its not display any image, but I need disabled display images it

    -have you set the URI of the Image of the time of the image?
    -deleteicon_enabled.gif N deleteicon_disabled.gif

    Concerning
    Meher Irk

    Published by: Meher Irk on October 24, 2010 12:18 AM

  • How to stop a sound and emit a sound signal according to the values of text?

    I have a text field and a button. When the button is clicked it displays 100 or 0 (vice versa). The value in the text field is saved and when the user opens the application upwards, the text field displays the last number (100 or 0). This is the code:

    import flash.events.MouseEvent;
    import flash.media.SoundChannel;
    import flash.ui.Mouse;
    
    var saveDataObject:SharedObject;
    var currentScore:Number; 
    options_mc.sound_btn.addEventListener(MouseEvent.CLICK, mute);
    
    
    init();
    function mute(event:MouseEvent)
    {
    
    if(currentScore == 100)
    {
    currentScore = 0
    options_mc.onoff_txt.text = String(currentScore);
    
    }
    else if(currentScore == 0)
    {
    currentScore = 100
    options_mc.onoff_txt.text = String(currentScore);
    }
    saveData();
    }
    function init():void
    {
    
    saveDataObject = SharedObject.getLocal("test");
    currentScore = 100;
    
    
    
    
    if (saveDataObject.data.savedScore == null)
    {
    
        saveDataObject.data.savedScore = currentScore;
    }
    else
    {
    
        loadData();
    }
    
    
    }
    
    function saveData():void
    {
    saveDataObject.data.savedScore = currentScore;
    
    saveDataObject.flush();
    
    }
    
    function loadData():void
    {
        currentScore = saveDataObject.data.savedScore;
    
        if (options_mc.onoff_txt) options_mc.onoff_txt.text=String(currentScore);
    }
    

    On a different layer in the timeline panel, I have a sound that lights up. I want the sound turns on if the value of the onoff_txt is equal to 100, and I want the sound to stop playing or not playing when the value is 0.

    The code failing that I came up with is the following: CheckSound();

    function CheckSound():void
    {
    if(options_mc.onoff_txt.text == "100")
    {
    tchannel
    = theme.play(0,9999);
    }
    else if(options_mc.onoff_txt.text == "0")
    {
    tchannel
    .stop();
    }
    }

    It does not at all, the sound comes not now or anything like that!

    If you call any function, the function will not work.  You must call this function whenever the program changes the values in the TextField.  What happens when the program starts and when you click the button, then work to call this function in the sections of the code.

  • Values of session variables not updated according to the values in the table

    Hello

    I have a problem with one of the session variable that is based on the USER login.

    My session variable "DeptID" has all the values associated with the user. I have in my external table, the USER and its corresponding departments. My init for this variable block is something like

    Select "DeptID", dept_id of user_table where user =': USER ';

    Now I use this variable on my main dashboard prompt and I'll show the results in the command prompt based on the results of sql. Here is my SQL something like

    SELECT 'Department '. "" Department name ""SH"where"Department. "" ID Dept ' = VALUEOF (NQ_SESSION. ("" DeptID ").

    With this method, everything works well and the command prompt displays the correct values.

    But the problem arises when a new Department is added to the current user. When new departments are assigned to the user, the new values does not appear in the drop-down on the line of dashboard until and unless the cache is purged and the server is restarted.

    Thinking that the cache is the issue, I have disabled the cache also in the nqsconfig.ini file. But then as the new values is not displayed. I see that in the file nqquery.log that the old values are sent to the database, that that is the session variable does not get updated with the new values according to the external table.

    You could someone please let me know what I'm missing here?


    Thank you

    Hello

    See this thread for the answer,

    Re: OBIEE external DB security does not completely.

    Thank you
    Swami

  • When the value to display in the time format double digital indicator... Changes in value.

    Hi all

    I can't display the values that I want. I have a value double say 320 sent to a digital indicator where I edited the properties of it to display in a time format that contains only minutes and seconds as Yes, 3:20 '. Unfortunately, it takes the value and change it to another value and display that. I don't know what is the issue. If anyone knows the solution... Please post!

    There is an image attatched!

    Thank you.

    I believe only then due to the fact that when I convert a timestamp value to double as 03:20, he gave me 320. So I thought that the reverse can be trying. Should I just enter the total amount of seconds and that will show the Minuteseconds I want?

    Thanks for the quick response.

  • read the values of an array element and by sending a digital output to a designated channel according to the value read from the table

    Hello world

    could someone help me before I get out of my hair. Here's my problem.

    I read 3 values of an array of 3 elements i.e. 1,2,3. These values are then compared to a constant value, example if the first element of the array is 1 and it meets the comparison condition can send a digital camera of output for that channel on data acquisition

    I want to be able to send a value from a table to its corresponding comparison and then on its designated channel on the acquisition of data, the whole point of this is due to the fact the table element will not always read the value 1,2,3 for example could be 2,3,1

    Here's one the vi I have so far

    If someone could help it would be much appreciated

    all the best

    brand

    Take time to explore the many examples included with LabVIEW that cover the basics.

    -Indexing table

    -reading a spreadsheet file

  • Remove the camera data displayed in develop Panel

    My young grandson watched some of my images in Lightroom and hit a few too many keys, and now the camera data were available through all my images. How can I remove these data, not the image itself, but the have displayed in the picture while I'm developing it? So frustrating...

    Thank you

    Tanya

    They view > Loupe Info > show the overlay of information (see the menu of keyboard shortcuts).

  • is it possible to toggle an element of tabular presentation according to the value of an element of the second?

    Hello world

    I have a tabular presentation based on a collection.   The column c050 (f30 cards) will be either Y/N.  If it is there, then I would enable the column c024 (f24 cards) (which is be based on lov radio button).  If the value of c050 = N, then disable c024.   There are potentially as many lines, and the c024 element would only be enable / disabled for the specific line.   So if line 1 is c050 = Y line 2 is C050 = N then rank 1 c024 is activated and 2nd c024 is disabled.  Hope that makes sense.

    I created a dynamic action called turn HMS fields.

    event = CHANGE

    selection type = jquery selector

    jQuery selector = input [name = "f30"]

    the condition EQUAL to

    value Y

    true action1 - enable, picker jquery, input [name = "f24"]

    real action 2 - alert, you added a sort of HMS.   There may be additional data to enter.  Thank you

    fake Action1 - disable jquery selector, input [name = "f24"]

    false action2 - alert, no worries of hms.

    Alerts in both cases show correctly... but nothing seems to happen to f24... What am I doing wrong?

    Thank you

    AGH! This is the first time you mention, that there is a radio button!  That changes a lot! As you can see, the format is different (f24_0001_0001) than what we discussed (f24_0001).

    Radio buttons have their own quirks.  My bad, I should have asked what you had.  But since you said your selectors original input were I just thought they are fields of text or something like that.

    How replace you a right drop-down list so that you can see all the work?  And understand it fully.

    Then you can work on the radio button option.

    If you don't get there... I will ask you to install an example in apex.oracle.com and give me credentials to sign in and have a look.

    I could re - try the js on my side with a radio, but it will take time.

    So, just to be clear... f30 is a drop down and f24 is a radio?

    See this line:

    $x_disableItem ("f24_" + row, true);

    Will NEVER find the radio buttons because it lacks the 3rd 0001 and 0002 (how many options do you have?)

    So maybe try you like this:

    $x_disableItem ("f24_" + line + '_0001', true);

    $x_disableItem ("f24_" + line + "_0002", true);

    ... keep for options...

    Do the same for the fake, of course.

    But I think that this needs a better approach if you have radio buttons.  I just need to get out.

    OK, go try things...

    Thank you

    -Jorge

  • sending of lov index instead of the value of display or code

    Hi I have a situation where the value of transition from am to my human workflow, my problem is everything they value that i beign selected through lov sending lov index instead of the actual value, for example when I select my lov instead of displaying the name of the country sendinding country it send this lov index i.e. 1
    my pagedef is 
    
    <list IterBinding="IntUsr1Iterator" StaticList="false"
              Uses="LOV_Countrycode" id="Countrycode" DTSupportsMRU="true"/>
    
    
    <methodAction id="approveUser" InstanceName="InternalUserAppDC"
                      DataControl="InternalUserAppDC" RequiresUpdateModel="true"
                      Action="invokeMethod" MethodName="approveUser"
                      IsViewObjectMethod="false">
    <NamedData NDName="country_of_origin"
                     NDValue="#{bindings.Countrycode.inputValue}"
                     NDType="java.lang.String"/>
    
     </methodAction>
    
    
    lov
    <af:selectOneChoice value="#{bindings.Countrycode.inputValue}"
                                  shortDesc="#{bindings.Countrycode.hints.tooltip}"
                                  id="soc3" simple="true">
                <f:selectItems value="#{bindings.Countrycode.items}" id="si3"/>
              </af:selectOneChoice>
    how can i pass selected value instead of input value
    Edited by: adf009 2013/05/07 10:55

    Published by: adf009 on 07/05/2013 10:56

    Hello

    I don't know much on the task list and its flow. But I guess that

    ...
    
    
    ....
    

    should be

    ...
    
     ....
    

    I've already shared it, but once again... Can go you through the get value selected SOC link

    -Neha...

  • The JSON data displaying on Blackberry Simulator or device not but waving poster

    Hello

    I use ripple to develop an application that makes jQuery/Ajax calls to a Web service that returns jSON. The returned data show in Wellington, but not on the emulator or the device. I use the 9800 torch Simulator, php to create the jSON and jQuery.

    Problem has been resolved. I made a mistake (a rookie mistake real) earlier in the code. I left out 'http://www.mydomain.com' when I did the ajax call to my php page. Everything works now. Thanks to all for trying to help with this.

  • issue by creating roles according to the jazn-data

    jdev 11.1.1.7

    In my application, I create roles in the jazn data files. When I run the application, the roles defined in the jazn file are not automatically created in the integrated weblogic.

    Considering that I have different applications in the same workspace, when I run it, the roles defined in their jazn is created in the weblogic. I can see a "deployment" tab, which is created in the jdev console and can see the continuation of console.

    [09: 42:07] download jazn-data users.

    [09: 42:07] update user 'john '.

    [09: 42:07] update user 'susan '.

    [09: 42:07] update user "steve".

    [09: 42:07] roles jazn-data download.

    [09: 42:07] remove the group existing 'Wendy '.

    [09: 42:07] group was created for the role of "Wendy".

    [09: 42:07] adding 'susan' to the group 'Wendy '.

    So what's the problem with my app that I am not able to see the roles are created in weblogic?

    Hi Fabrice,.

    Go to Applications - > Secure-> configure secure deployment

    Make sure that the following is checked.

    Redeploy your application using JDeveloper.

  • AF:table - change disabled property of input text according to the value of the attribute line

    Hello

    I use Jdev 12.1.2.

    I have a table with the number of lines.  Each line has a FutureCode attribute and other attribute FutureComments.  I want to make sure FutureComments is disabled unless the FutureCode of this line is is 'OTHER '.

    I tried to go to the text of the FutureComments component in the table and setting the property to the expression for disabled:

    #{row.bindings.FutureCode.inputValue == 'OTHER'? false: true}

    But it does not work.  I messed around with the parameters in the table (distribution of content, immediate change), but I did not get a configuration so that it can work.

    A little more information, the text input component are always disabled.  I also tried using the expression evaluator in the debugger to check the value of my #{row.bindings.FutureCode.inputValue}, but it is null, no doubt because he does not know what line I'm talking about.

    Any idea on this?  Thank you.

    Hello

    There the lov on future code?

    will not have operator you used? Try

    #{row.bindings.FutureCode.inputValue! = 'OTHER'}

    If this does not work

    Try

    #{row.bindings.FutureCode. attributeValue ! = 'OTHER'}


    Thank you

  • Dynamically change color according to the value of the field field

    I hope someone can help with my problem, I have not dealt with Java Script before please bare with me as I try to explain.  I tried searching everywhere for the answer but am getting lost a bit in some answers just so I was wondering if anyone on the forum can help.

    I am trying to create a reliable PDF form for a risk assessment. The user in the columns of the severity and probability input values and the value is generated automatically in the column risk classification. So I managed to get the number of risk rating to calculate automatically using the option calculate and select the value is the product of "Severity1", Likelihood1  It's great, so now I want to the field of evaluation may change the background color based on the value as follows:

    1-5 = Green

    6-10 = orange

    11-25 = Red

    I don't have any idea if this can be done via the Java Script or if it is not possible, I'm sure it will, but I need someone much smarter than me to guide me on how to do it. I guess it's the same concept as the conditional formatting in Excel.

    This is something like what I'm trying to achieve.

    Any help would be greatly appreciated

    Thank you

    Matt

    Gravity
    Likelihood
    Level of risk
    122
    236
    3412

    You will need to use a custom calculation script, something like:

    Custom calculation script

    (function () {}

    Get the field values as numbers

    var v1 = + getField("Severity1").value;

    var v2 = + getField("Likelihood1").value;

    Calculate the product

    var prod = v1 * v2;

    Set the value of this field;

    Event.Value = prod;

    Default background color

    var bg = color.white;

    Set the color orange

    Color.Orange = ['RGB', 1,.33, 0];

    Determine the background color on the product

    If (prod > = 1 & prod)<=5)>

    BG = color.green;

    } ElseIf (prod 5 > & prod)<= 10)="">

    BG = color.orange;

    } ElseIf (prod > 10) {}

    BG = color.red;

    }

    Set the background color of the field

    event.target.fillColor = bg;

    })();

Maybe you are looking for