How to filter data according to internal application and in case if returns nothing outside the query must return all the lines

create table ab (a number, b varchar2 (20));

Insert into ab

Select rownum, rownum. "" sample "

of the double

connect by level < = 10

create table bc (a number, b varchar2 (20));

Insert into BC.

Select rownum + 1, rownum + 1 | "" sample "

of the double

connect by level < = 10

Select * AB

where b in (select b BC where b = "2sample")

This query will return me 1 row, but there are cases where the value of the parameter b is null

and that it should return all rows in the table

as

Select * AB

where b in (select b BC where b = "2sample")

which return specific values, but I want to change in a way when the inner query returns nothing then outer query should return all the lines and works as

Select * AB;

Is it possible to put in a single query

Hello

You seem to ask for different things.  You want all the lines AB when

  1. The parameter ("2sample' in the example) is NULL, or when
  2. There is no corresponding row in the 2 tables (which could happen even if the parameter is not NULL)

?

Assuming you want the option 2, here's one way:

WITH got_rnk AS

(

SELECT ab.*

DENSE_RANK () (ORDER IN CASE

WHEN b (IN)

SELECT b

BC.

WHERE b = "2sample" - parameter

)

THEN "A".

OF ANOTHER 'B '.

END

) AS rnk

AB

)

SELECT a, b

OF got_rnk

WHERE rnk = 1

;

This does not assume b is unique in each table.

Thanks for posting the CREATE TABLE and INSERT statements; It is very useful.

Tags: Database

Similar Questions

  • HOW TO FILTER DATA IN MICROSOFT ACCESS

    HOW TO FILTER DATA IN MICROSOFT ACCESS BASED ON THE DATE AND TIME AND GIVE THE RESULT IN A TABLE?

    I need a few examples of files, can someone help me please?

    Fix your keyboard. If it has not been broken, be a little more polite and stop screaming.

    Research, are thousands of examples on the web related to the jet and sql database. This is a very basic select statement. Access to a query wizard that can then show the sql code. If you don't know how to design a query in access, you need a Basic for this tutorial. No question of LabVIEW here.

  • I have a problem with creative cloud applications is not to be downloaded or updated date on my i mac, current applications, I still have work. I uninstalled the cc application and re-installed but without success, in the apps tab there is no error code o

    I have a problem with creative cloud applications is not to be downloaded or updated date on my i mac, current applications, I still have work. I uninstalled the cc application and re-installed but without success, on the applications tab there is no code error only saying download error out area allowing you to charge applications call does not work... any suggestions?

    Hi James,

    Please follow the article: CC help | Download error in the applications tab of Creative Cloud Desktop Application to get this fixed number.

    Please let us know any questions.

    Thank you

    Yann Arora

  • How to take backup for VCSC, VCSE, MCU and TMS. I'm new in the world of video. A brief step by step would be appreciated

    How to take backup for VCSC, VCSE, MCU and TMS. I'm new in the world of video. A brief step by step would be appreciated.

    You can back up each server by following these steps:

    For VCS, see "Backup and recovery of data from VCS" section in the Cisco VCS Administrator Guide X8.5, page 340.

    For MCU, see "upgrade and save the MCU" section in the Cisco Telepresence MCU series online help 4.5, page 212.

    For MSDS, see back up and restore SQL Server databases you will back up the database of TMS 'tmsng' of the SQL Server itself.  It could either be hosted locally on the TMS server if you have installed TMS with the default settings, or an external user provided SQL server.

  • How to filter data in cursors within the procedure

    Hello

    Yesterday, I tried all night, but couldn't do it.

    I know that is incomplete, I just want to know how to filter the data based on the setting in

    Basically, here I want to get only the records that match the id_fichier


    create or replace PROCEDURE clearing_details (p_file_id in varchar2)
    IS
    strStatusCode VARCHAR2 (6);
    CURSOR PD1 IS
    SELECT COUNTRY_CODE, EOD_MARK OF LINK_STATUS WHERE FILE_ID is p_file_id


    Can someone help me on this please:


    Thanks for reading.

    Does do the same if you run the query itself in SQL * Plus with the same value you pass as a parameter?

    Without seeing your data and which parameter you're passing, we will fight help more as the concept itself works great as you have been demonstrated.

  • HOW to: Filter data in an html CFGRID with the defined query attribute tag

    Does anyone know how can I filter data in an html cfgrid, not through a link from AJAX, but perhaps by exposing some of the features of the code behind the controls cfgrid EXT?

    Any help would be greatly appreciated.

    --
    Jorge loyo

    I have it!

    MY ENTRY:

    <>
    ID = "searchString".
    name = "searchString".
    Type = "text".
    OnKeyUp is "ColdFusion.Grid.getGridObject('dg'). GetDataSource () .filterBy (myfilterfunc)"/ >

    MY FUNCTION

    MY GRID:

    <>
    name = "dg".
    Query = "employees".
    format = "html" >



  • SQL query: I want to know how to filter data...

    I want to filter these data

    yearDATA_TYPEproduct_nameamount
    20131Apple100
    20131Mango200
    20141Apple300
    20141Mango150
    20141banana250
    20151Apple350
    20152Apple300
    20153Apple320
    20152Mango400
    20153Mango400
    20153banana500

    In each year and each product, I want to filter the data that has no data in data type 1

    When he has not given in data of type 1, using data in data type 2.

    and if he has not given data type 2, use the data in data of type 3.

    This is the result I was expecting

    yearDATA_TYPEproduct_nameamount
    20152Mango400
    20153banana500

    Thanks for your help.

    Or more simply...

    SQL > ed
    A written file afiedt.buf

    1 with t (year, data_type, product_name, amount) as)
    2 Select 2013, 1, 'apple', 100 double Union all
    3 select 2013, 1, "mango", 200 double Union all


    4 Select 2014, 1, 'apple', 300 double Union all
    5 Select 2014, 1, "mango", 150 double Union all
    6 select 2014, 1, 'banana', 250 double Union all
    7 if he would choose 2015, 1, 'apple', 350 dual Union all
    8 select 2015, 2, 'apple', 300 double Union all
    9 select 2015, 3, 'apple', 320 double Union all
    10. Select 2015, 2, "mango", 400 double Union all
    11. Select 2015, 3, "mango", 400 double Union all
    12. Select 2015, 3, 'banana', 500 double
    13        )
    14-
    15 end of test data
    16-
    17 select year
    18, max (data_type) keep (first order by data_type dense_rank) as data_type
    19, product_name
    20, max (amount) to keep (first order by data_type dense_rank) as the amount
    21 t
    Group 22 by product_name, year
    23 * have max (data_type) Dungeon (first order by data_type dense_rank)! = 1
    SQL > /.

    YEAR AMOUNT DATA_TYPE PRODUCTION
    ---------- ---------- ------ ----------
    2015 mango 2 400
    2015 banana 3 500

    2 selected lines.

  • How to transfer data from a single card PXI-2576 to an another Committee of the PXI-2576 on the same chassis.

    I need to transfer a voltage using a PXI-5421 signal before a Council of PXI-2576 and then transfer it to an another Committee of the PXI-2576. For example I had set the signal of the ARB has then put 16 CH MUX 1(1st Switch), the value CH MUX 3 0 (switch 2) then read the MUX 3 voltage using a PXI-4071. I know that I can use the example of DMM Switch Handshaking.vi niSwitch for the rear. I'm just not sure how to transfer data to MUX 1, MUX 3?

    Thank you

    Denise Barajas

    Hi Denise,

    You must connect two switching modules to the outside. Signals may not actually be transferred through the PXI chassis backplane. Bottom of basket can only be used for communication by PCI bus and for the delivery of the trigger. You need to use external threads to physically send the signal of the first PXI-2576 to the second.

    There are two ways to connect signals to the PXI-2576, you can use a block of endings that mounts to the front of the module PXI, or you can use a cable with a block of external connection. You can then connect the signal cables to the connectors to screws on the terminal/connector block. More information about the options of connection to the NI PXI-2576 connectivity products Page.

    Hope this helps!

    Chris G

  • T440 - Sound does not switch between the internal speakers and headphones listening or return

    Hello community,

    Let me first explain how I assumed that the switch between headset and speakers should work:
    I turn on the music or anything else and if no headphones are connected, all sound from the internal speakers. Now if I plug headphones then sound comes exclusively from the helmet. If I go out then again the sound comes from the speakers and so on.

    In my case, the situation is the following:
    If I have no headset connected and turn on the music, then I heard if via the speakers. If I decide to continue to listen to this music through a headphone and plug them in, then the music continues to come from the speakers, but for example, the outlook notification sound is delivered in the headphones. It works vice versa.
    If I open, say youtube for a video, while having the headphone is plugged, I hear the sound through them. If I now unplugg, them, the speakers will remain silent.

    What can I do that if there is no external speakers connected (helmet, etc.) all sound will be played through the internal speakers, if I plug in a kind of external speaker, it's their part and if I unplugg it it switches back on the internal speakers?

    Thank you very much for your help!

    Best regards

    Look in Control Panel audio Realtek. It should be an option multistreaming, make sure it is set to unify all devices.

  • When a link to open another application and firefox is closed, Firefox opens but the link does not work

    I use Firefox on Mac OS 10.9.2, 29, this problem has occurred on the OS 10.8 ~ and various other versions of FF. I use 29 simply because I like it!

    The problem: Firefox is configured as the default browser in all directions it is possible to set as the default value. However, when I click on a URL from any application and Firefox is closed, Firefox opens opens, my last session of navigation tabs start, but the link does not open. I must return to the application and click the link again. This only happens on Firefox. I can put any other default browser and it will open the link in a closed state.

    This is happening to me, same, on Mac OS X 10.6.8 but only since I've upgraded to the latest version of Firefox, 32.0.1. I can click on a HTTP link in another application and Firefox becomes the active application, but it will not load a new tab for the link, as expected. Instead, it just sits there. I have to go back to the other application and click on the link a second time, during which point Firefox correctly open a new tab and load the destination URL.

  • Since the update I can't click on links placed horizontally, buttons etc. have uninstalled and reinstalled still do. Can not yet see how to get an older version that worked and ran a virus check. work of the Explorer

    Firefox has been updated automatically at 7, and now all the sites I go on horizontal active things, that you have to click will do nothing. for example in ebay I cannot access 'My ebay' and Facebook cannot click my profile or messages, I can't click on "Your Photostream" which means I can't use it in Flickr. I tried exploring and all these work, then firefox. I uninstalled and reinstalled and did a virus check system on top of the one active ongoing and nothing no change. I am at a loss what to do now. A relative offered to download an older version that worked, but I don't even no how to do this. I would appreciate help I can use firefox as at the same time, I'm stuck with exporer I hate. Thank you

    This problem may be caused by the extension of the Yahoo! toolbar

  • How to send data back to office applications

    Hi guys, I want to know all the possible ways to insert data in CRM OnDemand for legacy systems also the integration of options packages, it is best if you can tell me how to do it via web services, but no idea would be great. I ve heard talk of web links, but I Don t like that option so... can I do with the events of integration?

    Thank you!!

    There are several ways to extract data from CRM On Demand, including:

    * Export - Manual of the process, generate the CSV file containing data On Demand CRM
    * List/Analytics - manual process, export the contents of a list report to a CSV file
    Services - programmatic Web, developing an application that queries data within the CRMOD
    * Events - programmatic integration, use workflow to trigger the creation of the event and then query for events, namely that an operation occurs on a record (i.e. Insert new record of account)

    As to enter these data into another system, this will depend on the system and the methods for inserting data it makes available.

    I hope this helps.

    Thank you
    Sean

  • How to filter dates between the current date and the number of dates past

    Hello

    On the answers, how can I do to return a report that contains data between the current dates and 31 days in the past?

    Users want to connect display the report and the report should show only data 31 days to the date of the day... How would I be able to set it up on the answers that since I have not access to RPD?

    Please let me know

    Thank you

    use the date filter between current_date and timestampadd (sql_tsi_day, -31, current_date)

    fixed

  • How to filter Dates with viewCriteria - ADF 10.1.3.3

    Hi Comunity I need to filter a Date in a VO with a viewCriteria I try with this code, but does not work:

    ViewCriteria vc = this.createViewCriteria ();
    Vcr1 ViewCriteriaRow = vc.createViewCriteriaRow ();
    VCR1.SetAttribute ("FlgEstado", "AC");
    VCR1.SetAttribute ("DateClose",">" "2008-11-01 01:00:00.0'" ");
    VC. Add (VCR1);
    this.applyViewCriteria (vc);
    this.executeQuery ();

    How can do this?

    Thank you!!!.

    TryTo use a to_date function, then assign the dateClose something like to_date (' dd/mm/yyyy ',' 18/08/1999')

  • How to filter data

    Hello

    It's the database version 11.2.0 oracle. Under query executed. I don't want a single value not display set to FALSE.

    and also not to display a value when I went from condition is 'TRUE '.

    SQL > select the value of the parameter $ v where name in ('dg_start', 'dg_file1');

    VALUE

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    FAKE

    +ABCDATA/iebrnd04sit/dg_RT1.dat

    2 selected lines.

    Not sure I understand, but here's a try:

    VAR V_CONDITION VARCHAR2 (10);

    EXEC: V_CONDITION: = 'FALSE ';

    Select the value

    de)

    Select name, value

    , max (case where name = 'dg_start' then end value) over() as dg_start

    the parameter $ v where name in ('dg_start', 'dg_file1')

    )

    where name = 'dg_file1' and dg_start =: V_CONDITION

    ;

Maybe you are looking for