SQL query to find the value of a column as well!

Hi all

I have to write a query that needs to retrieve the value of a column in table B if the column value is Null in the Table A. Please find below the sample table.

Table A:
*******
EmpNumber ID
------------------------------
1 12345
2
3 14789
4
5 74563

Table B:
*******
EmpNumber ID
-----------------------------
1 12345
2 78451
3 14789
4 12212
5 74563

In the table a second and third rows have value for EmpNumber. The query should look for table B for EmpNumber value. Please advise me to make this request.

Thank you

This?

select      a.id,
     nvl(a.empnumber,b.empnumber) empnumber
from tabA a, tabB b
where a.id = b.id;

Tags: Database

Similar Questions

  • SQL query to find the total number of source based nonsource passangersbetween source and destination station and passenger station on the same chekindate

    Hello

    SQL query to find the total number of source based nonsource passangersbetween source and destination station and passenger station on the same chekindate.

    Please help on this script and let me know if you need more details.

    ---

    You use a SELECT statement.  Let me know if you need more details.

  • Report, SQL query based on the values of the elements (question SQL)

    Hello

    I use APEX 4.0 with Oracle 10 g r2 under Windows XP Pro SP3.

    I have an interactive report and a menu with a few items to filter the report.

    It works with most of the elements, but my problem is to select lists that have additional values, for example:
    SELECT '(null)' display_value, 'NULL' return_value FROM DUAL
    UNION ALL
    select distinct(SPAT_AREA_NAME) display_value, SPAT_AREA_NAME return_value 
    from SPATIAL_POINTS
    order by 1
    and I will return null as ' (return '%').

    For example, if the user selects "(null)", the report should return all rows with a NULL value in the column AREA_NAME.
    If he chooses "", the report should return all the lines. "
    and if the user selects a value, the report should return all the lines containing the value in column AREA_NAME.

    I don't know how to build my application. I tried with the CASE statements, DECODE, etc... but I still can't!

    My report query is for now:
    select SPAT_ID,
     SPAT_ACCL_NAME,
     SPAT_AREA_NAME,
     SPAT_CLASS,
     SPAT_NUMBER,
     SPAT_PT,
     SPAT_TYPE,
     SPAT_STATUS,
    from SPATIAL_POINTS 
    where 
     upper(SPAT_AREA_NAME) LIKE upper(:P3_FILTRE_AREA_NAME)  AND
     upper(SPAT_ACCL_NAME) LIKE upper(:P3_FILTRE_ACC_NAME) AND
     upper(SPAT_CLASS) LIKE '%'||upper(:P3_SPATIAL_CLASS)||'%' AND
     instr(upper(:P3_SPATIAL_TYPE_VALUES),upper(SPAT_TYPE)) > 0 AND
     instr(upper(:P3_SPATIAL_STATUS_VALUES),upper(SPAT_STATUS)) > 0 AND
     instr(upper(:P3_SPATIAL_POINT_VALUES),upper(SPAT_PT)) > 0
    Any idea?

    Thank you!

    Yann.

    Hello

    Then, assuming that spat_accl_name is not a string value "NULL" then you can try this...

    SELECT spat_id,
           spat_accl_name,
           spat_area_name,
           spat_class,
           spat_number,
           spat_pt,
           spat_type,
           spat_status,
           ROUND(spat_cumul,
                 (SELECT up_number_precision
                  FROM   user_preferences
                  WHERE  UPPER(up_nice_login) = UPPER(v('APP_USER'))))
              AS "SPAT_CUMUL"
    FROM   spatial_points
    WHERE  :p3_filtre_acc_name IS NULL AND spat_accl_name IS NULL
           OR(CASE
                 WHEN :p3_filtre_acc_name = '%' THEN NVL(spat_accl_name,'NULL')
                 ELSE :p3_filtre_acc_name
              END = NVL(spat_accl_name, 'NULL'))
    

    See you soon

    Ben

  • query to find the dependent task, attached to the task on a response in OIM 11 g

    can someone help me to do a sql query to find the dependent task, attached to the task on a response in OIM 11 g

    Published by: user13331347 on Sep 3, 2012 14:09

    Use under query to find the dependent task in OIM 11 g: -.

    Select pkg.pkg_name, mil.mil_name, rsc.rsc_data, rsc.sta_key, sta.sta_status, sta.sta_bucket, mil2.mil_name
    pkg pkg, tos tos, mil mil, mil mil2, rsc rsc, sta sta, rgm the rgm
    where pkg.pkg_key = tos.pkg_key
    and tos.tos_key = mil.tos_key
    and mil.mil_key = rsc.mil_key
    and rsc.sta_key = sta.sta_key
    and rgm.rsc_key = rsc.rsc_key
    and rgm.mil_key = mil2.mil_key
    order of pkg.pkg_name, mil.mil_name, rsc.rsc_data, sta.sta_status, mil2.mil_name

  • How to get the value of a column in sql query?

    Hi, anyone knows how to get the value of a column in sql query?

    Here is my code, the value must be 1350079224397 in my PB, but I get 0

    QString query ("SELECT version FROM db_version");

    QVariant result = sda.execute (query);
    QVariantMap versionMap = result.toList () such () .toMap ();
    If (! versionMap.IsEmpty ())
    {
    qDebug()<"Version: "=""><>
    }

    OK, I have the solution

    QString query ("SELECT version as version FROM db_version");

  • SQL query to display the sum of the values of each June and December

    Hello having problems of construction of a query to the list SQL query to display the sum of the values of each June and December each year.

    My Table;

    TABLE name: MONTH_TERM

    Fields with values:

    TERM_KEYMONTH_ACTUALMONTH_DATE
    8250001/11/2015 0:00
    8245001/12/2015 0:00
    8240501/01/2016 0:00
    8240001/02/2016 0:00
    8245001/03/2016 0:00
    8242501/04/2016 0:00
    8243501/05/2016 0:00
    8241006/01/2016 0:00
    8240901/07/2016 0:00
    8241501/08/2016 0:00
    8242009/01/2016 0:00
    8242210/01/2016 0:00
    8243611/01/2016 0:00
    8255601/12/2016 0:00
    8256801/01/2017 0:00
    8262402/01/2017 0:00

    What I would like to see in a query result:

    TERM_KEYMONTH_ACTUALMONTH_DATETotal of 6 months
    8250001/11/2015 0:00
    8245001/12/2015 0:00950
    8240501/01/2016 0:00
    8240001/02/2016 0:00
    8245001/03/2016 0:00
    8242501/04/2016 0:00
    8243501/05/2016 0:00
    8241006/01/2016 0:002525
    8240901/07/2016 0:00
    8241501/08/2016 0:00
    8242009/01/2016 0:00
    8242210/01/2016 0:00
    8243611/01/2016 0:00
    8255601/12/2016 0:002658
    8256801/01/2017 0:00
    8262402/01/2017 0:00

    ---

    Here's my query:

    Select

    "TERM_KEY,"

    "MONTH_ACTUAL,"

    to_char(MONTH_DATE,'MM/YYYY') MONTH_DATE,

    DEAL to_char (MONTH_DATE, 'MM')

    WHEN '06' THEN (SELECT SUM (MONTH_ACTUAL)

    OF MONTH_TERM

    WHERE the to_char (MONTH_DATE, 'MM') between 1 and 6

    AND term_key = 82)

    WHEN '12' THEN (SELECT SUM (MONTH_ACTUAL)

    OF MONTH_TERM

    WHERE the to_char (MONTH_DATE, 'MM') between 7 and 12

    AND term_key = 82)

    ELSE null

    END as SIX_MO_CUMM,

    of MONTH_TERM

    where term_key = 82

    It's my results:

    TERM_KEYMONTH_ACTUALMONTH_DATETotal of 6 months
    8250001/11/15 0:00
    8245001/12/15 0:003608
    8240501/01/16 0:00
    8240001/02/16 0:00
    8245001/03/16 0:00
    8242501/04/16 0:00
    8243501/05/16 0:00
    8241001/06/16 0:003717
    8240901/07/16 0:00
    8241501/08/16 0:00
    8242001/09/16 0:00
    8242210/01/16 0:00
    8243601/11/16 0:00
    8255601/12/16 0:003608
    8256801/01/17 0:00
    8262401/02/17 0:00

    Any ideas on how to fix would be great

    Select term_key,

    month_actual,

    month_date,

    case mod (to_char (month_date, 'mm'), 6)

    When 0 then sum (month_actual)

    During)

    term_key partition

    order of month_date

    between the previous month '5' interval and the current line

    )

    end '6 MONTHS in TOTAL'

    from tbl

    order of term_key,

    month_date

    /

    TERM_KEY MONTH_ACTUAL MONTH_DAT 6 MONTHS TOTAL
    ---------- ------------ --------- --------------
    82 500 NOVEMBER 1ST, 15TH
    82 450 1 DECEMBER 15 950
    82 405 1 JANUARY 16
    82 400 1 FEBRUARY 16
    82 450 1ST MARCH 16
    82 425 1ST APRIL 16
    82 435 1 MAY 16
    82 410 2525 1 JUNE 16
    82 409 1 JULY 16
    82 415 1ST AUGUST 16
    82 420 16 - SEP - 01

    TERM_KEY MONTH_ACTUAL MONTH_DAT 6 MONTHS TOTAL
    ---------- ------------ --------- --------------
    82 422 1 OCTOBER 16
    82-436 NOVEMBER 1, 16
    82 556 2658 1 DECEMBER 16
    82 568 1 JANUARY 17
    82 624 1 FEBRUARY 17

    16 selected lines.

    SQL >

    SY.

  • How to find a value in any column of the table - essentially a search

    Hi guys,.

    Thanks in advance for your help.

    I'll try to find a value in any column of the table? How can I do?

    An example of value would be "FEDERAL."

    Using Oracle 11 g and SQL Developer.

    Thank you

    It's a question that is asked in the past several times (but not recently from what I remember).

    Michaels has provided in the past, solutions which are quite clever, just using SQL...

    10g of solution

    Michaels > var val varchar2 (5)

    Michaels > exec: val: = "Sub".
    PL/SQL procedure successfully completed.

    Michaels > select distinct substr (: val, 1, 11) "keyword."
    substr (table_name, 1, 14) "table."
    substr (t.column_value.getstringval (), 1, 50) ' / value of the column.
    CLO.
    Table
    (xmlsequence
    (dbms_xmlgen.getxmltype ("select" | column_name))
    || 'from ' | table-name
    || ' where upper (')
    || column_name
    || ') as superior (' %' |: val)
    || '%'')'
    ) .extract (' LINES/rowset / * "")
    )
    ) t
    -where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'SERVICES')
    order of the "Table".

    11g upwards

    SQL > select table_name,.
    column_name,
    : search_string search_string.
    result
    from (select column_name,
    table_name,
    "ora: view("' ||) " table_name | "") / LINE /' | " column_name | "[ora:contains (text ()," %' |: search_string | ")]. (%») > 0]' str
    CLO
    where table_name in ('EMP', 'Department')),
    XMLTable (columns str result varchar2 (10) path '.')
    /

    TABLE_NAME COLUMN_NAME SEARCH_STRING RESULT
    ------------------------------ ------------------------------ -------------------------------- ----------
    DEPT                           DNAME                          es                               RESEARCH
    EMP                            ENAME                          es                               JAMES
    EMP                            JOB                            es                               SALESMAN
    EMP                            JOB                            es                               SALESMAN

    4 selected lines.

  • SQL query to get the number of days monthwise

    Hello
    I'm new to sql, can someone please tell me query to find the number of days between the two dates months wise.
    say
    FIRSTDATE last date
    21/03/2011-25/06/2011

    March April May June
    9 22 23 18

    Hello

    Welcome to the forum!

    Here's one way:

    WITH     all_dates     AS
    (
         SELECT     start_date + LEVEL - 1     AS a_date
         FROM     (
                   SELECT     TO_DATE ('21/03/2011', 'DD/MM/YYYY')     AS start_date
                   ,     TO_DATE ('25/06/2011', 'DD/MM/YYYY')     AS end_date
                   FROM     dual
              )
         CONNECT BY     LEVEL     <= end_date + 1 - start_date
    )
    SELECT       TO_CHAR ( TRUNC (a_date, 'MONTH')
                , 'fmMonth YYYY'
                )               AS month
    ,       COUNT (*)               AS num_days
    FROM       all_dates
    WHERE       a_date - TRUNC (a_date, 'IW')     < 5
    GROUP BY  TRUNC (a_date, 'MONTH')
    ORDER BY  TRUNC (a_date, 'MONTH')
    ;
    

    What is a 'working day '? I guess you mean every day except Saturday or Sunday, but the query aboveare sometimes figures less than you have asked:

    MONTH             NUM_DAYS
    --------------- ----------
    March 2011               9
    April 2011              21
    May 2011                22
    June 2011               18
    

    Are a few days working on Saturday or Sunday? How do you get the 22 working days in April 2011 and 23 in may?

    SQL is good at obtaining results with a variable number of rows, but you have to say exactly the desired number of columns when you write the query.
    If you really need the output of the way you said, with any number of columns, then watch in swing or a grouping of the chain . See the FAQ forum
    https://forums.Oracle.com/forums/Ann.jspa?annID=1535
    "4. How can I convert rows to columns.

  • How to find the value closest in the table?

    Hi all

    I just want to find the value closest from the string table. That I joined herer as an image.

    Now, if I want to find the value of 350 of the string table and that's not in the table in the output array there should be more close 350 display value...

    Thank you for the support

    Vinal Gandhi

    Hi G Vinal,

    something like the joint comes to my mind.

    It may be useful

    Mike

  • Look for the logic find the value of m and c of this equation y = mx + c.

    Hello

    I have 4 points for example = 3.38276, 0.375866 xi

    Yi = 3.37749, 0.281924

    using this tip, I want to find the value of m and c.

    You please suggest me some logic to solve this equation using labview programming.

    I tried with one solution, but in this case I do not have the correct answer. Here as an attachment, there is vi help I tried to solve my equation, but in this case the value that never got as a response it is dissatisfied with the equation, means if I replace the value of m and c eqation then it must be L.H.S = R.H.S, but I don't have the right solution.

    You please guide me.

    Thank you very much.

    Why do you think that the results are incorrect? I put your numbers in your code and the result on a XY Chart Wescott, I then bunk which with more than 20 values with a value ranging from 0.6 to 3.2 x and use factors calculated in your code to generate values of Y. The two overlap almost exactly...

    Mike...

    BTW: There is a linear adjustment integrated into LV VI

  • How to find the value max and min for each column in a table 2d?

    How to find the value max and min for each column in a table 2d?

    For example, in the table max/min for the first three columns would be 45/23, 14/10, 80/67.

    Thank you

    Chuck,

    With color on your bars, you should have enough experience to understand this.

    You're a loop in the table already.  Now you just need a function like table Max and min. loop.  And you may need to transpose the table 2D.

  • SQL query to represent the data in the graph bar

    Hello

    JDev 11.1.1.5.0

    We must create a dashboard to track the translation. We have created the ADF table with buttons 'Create', 'Update' and 'Delete' to manipulate the table.

    Our DB table structure is

    File_id (PK), File_Name, ToSpanish - ARE (YES/NO), beginning of the ToSpanish, ToChina(YES/No), ToChina-Date... etc.

    Once the translated file required language then user must update the DB table using the button "Update".

    So far, we have implemented the requirement above.

    We need represent the status of the translation in the graph bar with the language as X access and file count get access Ex: Spanish-100 China - 200 files files

    Please suggest the sql query to retrieve the necessary info from the DB table that can be represented in the graph bar. Also, it would be great, if you can provide a pointers to create a bar chart.

    Thanks in advance,

    MSR.

    If you set your major increment and minor than 1, then you won't not show decimal points.  You can try setting these 10 or 100 to reach your goal.

    Subtype = "BAR_VERT_CLUST" >

                 

  • What is the query to find the name of all applications for all EBS R12.1.3 modules?

    What is the query to find the name of all applications for all EBS R12.1.3 modules?

    With regard to:

    Mr. Shahzad Saleem

    Try:

    SELECT * FROM fnd_concurrent_programs_vl;

  • Where can I find the value of ss_nm_jvm_startup_properties?

    Hello

    I am trying to reset the password for the user weblogic using the document Doc-ID 1949675.1

    I am stuck at step 4

    B. start AdminServer:

    Java $ < s_nm_jvm_startup_properties > - Dweblogic.system.StoreBootIdentity = true - Dweblogic.Name = AdminServer weblogic. Server

    Where:

    < s_nm_jvm_startup_properties > is the same as the variable value of context ss_nm_jvm_startup_properties

    Where can I find the value of s_nm_jvm_startup_properties.

    I searched the support site and google it without any result.

    I'm new in EBS and try to upgrade the EBS 12.2.0 to 12.2.4

    Thank you

    Salman

    Hello

    Application contextfile $INST_TOP/appl/admin find the setting "nm_jvm_startup_properties".

    grep nm_jvm_startup_properties context_file.xml

    Thank you

    A H E E R X

  • Query to find the Pages and the list of permissions associated with a particular role in PS

    I want a query to find the Pages and the list of permissions associated with specific roles in PS.

    For example, if we see the role of manager accounts payable, it conatins Pages and the list of permissions.

    But, to get everything in EXCEL sheet by Manuel priocess's BIG job. So, can someone give me the query.

    Please try under queries

    The roles assigned to the list of Perm:

    SELECT B.ROLENAME

    OF PSCLASSDEFN A, PSROLECLASS B

    WHERE (A.CLASSID = B.CLASSID

    AND A.CLASSID =: 1).

    List of Perm pages can access:

    SELECT B.MENUNAME, B.BARNAME, B.BARITEMNAME, B.PNLITEMNAME, C.PAGEACCESSDESCR, B.DISPLAYONLY

    OF PSCLASSDEFN A, PSAUTHITEM B, PSPGEACCESSDESC C

    WHERE (A.CLASSID = B.CLASSID

    AND A.CLASSID =: 1

    AND B.BARITEMNAME > ' '

    AND B.AUTHORIZEDACTIONS = C.AUTHORIZEDACTIONS)

Maybe you are looking for

  • Issues of BIOS and HDD - Portege R830 passwords

    HI - looking for advice here. Have just updated the latest BIOS for my R830 - version 3.10 (EC version 1.20). Update went without a hitch. My fingerprint reader is kaput - and I will travel far for a while - so need to strengthen security on the lapt

  • Cover of P50

    I noticed a few differences in the cover works in my old T510 and the new P50. I see that the cover on the P50 is not lock, which is fine. However, when closing down the lid - to the position where it is too close to the keyboard (around 5 to 15 degr

  • Finger undetected, even if the stylus is detected

    For my ThinkPad 2, I got just back from the centre of repair official, all of a sudden the touch screen do not read any finger touches or slips etc. at all. Simply enter my digitaliseur pen. Any thoughts?

  • Windows Live Mail error code 0 x 80040154

    Hey everybody, I have recently installed Windows Live Mail, but I have a few problems with it. Whenever I try to start the program, a dialog box appears saying that "Windows Live Mail could not be started. It cannot be installed correctly. Make sure

  • new graphics card for a R4 Aurora

    I have a NVIDIA GeForce GTX 690 whats a good compatible upgrade for $300