How to write the query

Hello

How to write the sql query

I have three type of table as

1 table emp

EMP_ID FIRST_NAME DEPT_ID

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

1 kumar 10

2 sam                          20

3 30 damu

2 table dept

EMP_ID SALE_ID DEPT_ID

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

1 101 10

2 102 20

3 103 30

3. table sale

EMP_ID SALE_ID SALE_AMT

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

1 101 7

2 102 8

3 103 9

I want the result as

EMP_ID DEPT_ID SALE_AMT

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

1                10                  7

Thank you

Are you looking for this?

SELECT T1. EMP_ID,

T1. DEPT_ID,

W3M SALE_AMT

FROM EMP T1,

SALE T3

WHERE T1. EMP_ID = T3. EMP_ID;

OUTPUT:

EMP_ID DEPT_ID SALE_AMT

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

1         10          7

2         20          8

3         30          9

If this is not the case, after the actual output, you need. Because that gives you the amount of sales deptwise

Tags: Database

Similar Questions

  • How to write the query option in expdp

    Hi Please someone help me how to write the query option in expdp... .in expdp using the query option...

    where AM columnname between 5 May 12 02:57:00.000' and ' 02:59:59.999 6 May 12: ';


    Please do what is necessary...

    Pavan Kumar says:
    QUERY = (columnname scott.test: "where between 5 May 12 02:57:00.000 h ' and ' 6 May 12 AM 02:59:59.999'")

    Who will fail in databases, because you assume nls_date_format. How it is difficult to put to_date() surround channels? Rather than play with quotation marks, using one parfile thusly.

    query=table_owner.table_1:"where business_date between to_date('20120505025700 am','yyyymmddhhmiss am') and to_date('20120505025959 am','yyyymmddhhmiss am')"
    query=table_owner.table_2:"where business_date between to_date('20120505025700 am','yyyymmddhhmiss am') and to_date('20120505025959 am','yyyymmddhhmiss am')"
    query=table_owner.table_3:"where business_date between to_date('20120505025700 am','yyyymmddhhmiss am') and to_date('20120505025959 am','yyyymmddhhmiss am')"
    

    You do not have to have all the clauses in a single line, as they are side by side parfile, which would be enough. For this reason parfile is better than the command line in order to avoid all the back-citing dance.

  • How to write the query with parameters below and is null


    Hi, I need to recover the data if the parameter is passed on the ground, else retrieve all records where the field is null

    Example of


    CREATE TABLE DEPT
    (DEPTNO NUMBER (2),)
    DNAME VARCHAR2 (14).
    LOC VARCHAR2 (13));

    INSERT INTO DEPT VALUES (10, 'ACCOUNTING', 'NEW YORK');
    INSERT INTO VALUES DEPT (20, 'SEARCH', 'DALLAS');
    insert into dept values (30, 'SALES', 'CHICAGO');
    INSERT INTO VALUES DEPT (40, 'OPERATIONS', 'BOSTON');

    ALTER table dept add (object_id number);
    insert into dept values (50, 'OPERATIONS', 'BOSTON', 1);
    insert into dept values (60, 'OPERATIONS', 'BOSTON', 1);
    INSERT INTO VALUES DEPT (70, 'OPERATIONS', 'BOSTON', 2);

    Select * from Department where object_id =: p_object_id

    If I pass the object_id 1, it shloud retrieve the values of dept with object_id 1, but if I don't pass the object_id, it must retrieve all records where object_id is null

    IF 1 is passed as the id of the object, he must recover, 50, 60, if 1 is not passed as object_id it should 10,20,30,40 retive

    It works fine for me separately as,.

    Select * from Department where object_id =: p_object_id - 1

    Select * from Department where the object_id is null;

    Is it possible to do in a single query.

    Thank you

    SELECT *
    FROM dept
    WHERE object_id = :p_object_id
    OR (object_id is null and :p_object_id is null)
    

    is an approach.  It's a little talkative, but the meaning is clear.  If you can identify a value that would never appear in the data (for example-1)

    WHERE nvl( object_id, -1 ) = nvl(p_object_id, -1 );
    

    Justin

  • How to write the select query for it

    Hello

    I had an html form and the area I drop down and he needs to select several values in the drop-down box. When I select multiple values then I have to write the query to SQL select statement.

    When I try to write the select statement and trying to run I get the error message.

    Select * from Table

    where emo_no = '1,2,3 '.

    That's how I write the query please suggest me how to write the query to select several values in the drop-down box.

    Thank you

    Use the keyword sql 'in '.  If you don't know how, I've heard good things about the book Teach Yourself SQL in 10 Minutes by Ben Forta.

  • How to write a query to return rows with the varchar column that contains even a single occurrence of the characters, such as Ÿ and

    How to write a query to return rows with the varchar column that contains even a single occurrence of the characters, such as Ÿ and

    I have a table whose columns with values such as

    MINNEAŸPOLIS and ¿VV ¿A

    Only the characters that are allowed in this column are alphabets, numbers, spaces, points and supports.

    Please help to write a SQL SELECT with Regexp_like query or any other option.

    Thanks to you all! Under query worked for me. Thank you Frank to explain the concept of hooks inside regexp_like.

    SELECT * FROM testspecial, WHERE REGEXP_LIKE (sampletext, "[^] ^ A - Z ^ a - z ^ 0-9 ^ [^.]") ^ {^} ^]') ;

  • How to write a query for the data exchange between two columns?

    How to write a query for the data exchange between two columns?

    I tried a request, does NOT work.
    update tmp t1 set t1.m1=t1.m2 and t1.m2=(select t2.m1 from tmp t2 where t2.student_id = t1.student_id)
    Thank you.

    Published by: user533361 on October 23, 2009 14:04

    Just plain and simple:

    update tmp t1
     set t1.m1=t1.m2,
         t1.m2=t1.m1
    /
    

    SY.

  • How to frame the query?

    Uses oracle ebs r12

    I have a table of data is

    Operation_seq Type statusflag SeqNum
    1 10A Y
    2 20 b Y
    3 30 c Y
    4 40 D Y
    5 50 e N
    6 60 f Y

    I want to write a query in which I want to take only 1 record operation_seq = 50 and Statusflag is N and all other interventions seq status is there.

    My query must return only 50 operation when the status of 50 is N and any other status is Y.

    Help, please.

    Thank you
    Lavan

    LAVANKV wrote:
    This statusflag can be (null or N), then how to frame the query.

    Simply wrap the statusflag with NVL column, you should be good.

    SQL> with t
      2  as
      3  (
      4  select 1 seqnum, 10 operation_seq, 'a' type, 'Y' statusflag from dual union all
      5  select 2 seqnum, 20 operation_seq, 'b' type, 'Y' statusflag from dual union all
      6  select 3 seqnum, 30 operation_seq, 'c' type, 'Y' statusflag from dual union all
      7  select 4 seqnum, 40 operation_seq, 'd' type, 'Y' statusflag from dual union all
      8  select 5 seqnum, 50 operation_seq, 'e' type, '' statusflag from dual union all
      9  select 6 seqnum, 60 operation_seq, 'f' type, 'Y' statusflag from dual
     10  )
     11  select seqnum, operation_seq, type, statusflag
     12    from (
     13            select t.*, count(decode(statusflag, 'Y', 1, null)) over() cnt_1, count(*) over() cnt_2
     14              from t
     15         )
     16   where operation_seq = 50
     17     and nvl(statusflag, 'N') = 'N'
     18     and cnt_2-cnt_1 = 1
     19  /
    
        SEQNUM OPERATION_SEQ T S
    ---------- ------------- - -
             5            50 e
    
  • No idea how to write this query

    Hi, My Data is as below

    DocNum doc_date type of amount
    1154 15 November 11 232501.5 invoice
    200206 4 November 11 - 243672.64 credit memo
    Note flow 111 5 November 555.22 11

    Output must be

    DocNum doc_date amount Type AmountDR AmountCR
    1154 232501.5 15 November 11 Bill 232501.5
    Note credit 200206 4 November 11 - 243672.64 - 243672.64
    Note flow 111 5 November 555.22 11 555.22

    If the amount is > 0, then it must be displayed in the value of the amount to be AmountDR
    If amount < 0 then it must be displayed in the value of the sum amount CR



    Can help how to write this query
    with sample_table as (
                          select 1154 Docnum,date '2011-11-15' doc_date,232501.5 Amount,'Invoice' type from dual union all
                          select 200206,date '2011-11-04',-243672.64,'Credit Memo' from dual union all
                          select 111,date '2011-11-05',555.22,'Debit Memo' from dual
                         )
    select  Docnum,
            doc_date,
            Amount,
            type,
            case
              when Amount >= 0 then Amount
            end AmountDR,
            case
              when Amount < 0 then Amount
            end AmountCR
      from  sample_table
    /
    
        DOCNUM DOC_DATE      AMOUNT TYPE          AMOUNTDR   AMOUNTCR
    ---------- --------- ---------- ----------- ---------- ----------
          1154 15-NOV-11   232501.5 Invoice       232501.5
        200206 04-NOV-11 -243672.64 Credit Memo            -243672.64
           111 05-NOV-11     555.22 Debit Memo      555.22
    
    SQL> 
    

    SY.

  • Open XML, how to write the path

    Hello

    I'm new to the Blackberry development and I hope you can help me with my problem. I try to work with an XML file, and so far, all that does very well as long I had the xml file, I work on, in the folder of my java application and deyployed using the desktop software. Now, I tried to put the file somewhere else on the Blackberry and I don't know how wirte the path to the source code. I tried the following, but it seems to be bad:

    private static String _xmlFileName = "file:///store/home/user/documents/test.xml";
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = factory.newDocumentBuilder();
                InputStream inputStream = getClass().getResourceAsStream( _xmlFileName );
                Document document = builder.parse( inputStream );
    

    I hope you can give me a hint, how I write the correct path?

    Thank you very much!

    Best regards, jtr87

    PS: Sorry for my bad English, but I did not use it very often.

    You need to do something like that to get your InputStream:

    /** * @return an open InputStream for a file, or null if file does not * exist. * @throws IOException if there is an error opening the file */InputStream getInputStream(String name) throws IOException {
        FileConnection fc = null;
        try {
            fc = (FileConnection) Connector.open(name, Connector.READ);
            if (fc.exists()) {
                return fc.openInputStream();
            }
        } finally {
            if (fc != null) {
                try {
                    fc.close();
                } catch (Exception ignored) {
                }
            }
        }
        return null;
    }
    

    Notice that you must close the FileConnection at some point, regardless of if the call to openInputStream worked.

  • How to write the script in FDMEE below.

    How to write the script in FDMEE below.

    Script below is the FDM Script.How write in FDMEE.

    If (varValues (14) '113101' =) OR (varValues (14) '113201' =) OR (varValues (14) '113301' =) OR (varValues (14) = "252111") OR (varValues (14) '156101' =) then

    Result = "21_asd."

    Please help me on this issue.

    Kind regards

    Satheesh, S

    If you want to determine the id of the target account your opening assignment statement must be:

    Account = fdmRow.getString ("ACCOUNTX")

    As if - elif-instructions else keep lowercase stream operators. If you continue a command on multiple lines, then place parentheses is

    If (account == "113101") or (account == "113201") or (account == "113301") or (account == "113401") or (account == "113501") or (account == "113601") or (account == "215101") or (account == "215201") or (account == "215301") or (account == "215401") or (account == "215501") or (account == "215601") or (account == "252111") or (account == "156101"):

    fdmResult = "21_ADNIP".

    should be (also get rid of the unnecessary parentheses)

    If (account is "113101" account is "113201" or account is '113301' account is "113401" or account is "113501" or account is "113601" or account is "215101" or account is "215201" or account is "215301" or account is "215401" or account is "215501" or account is "215601" or account is "252111" or account is "156101"):

    fdmResult = "21_ADNIP".

  • How to write the even-odd fill feature?

    How to write the even-odd fill feature?

    Maybe like this:

    app.executeMenuCommand ('* ');

    01.jpg

    There is a command in the PathItem object named evenodd. I think that if you change the property of evenodd and get a member of a composite path path, you can achieve a desired result.

  • How to write the 'C' alpabelt within a circle of author?

    Hello

    How to write the symbol of copyright on first Pro CC (ie the alpabelt 'C' inside a circle) ?

    Thank you

    On a Mac, Option + G.

    MtD

  • ADF: How to print the query and the query passed into the class executeQueryForCollection methof impl VO parameters.

    Hello

    Kindly let me know how to print the query, and the parameters passed to it? I tried with the params parameter in super.executeQueryForCollection (qc, params, noUserParams); but could not succeed.

    I need save the query and the parameters passed to it. Kindly help.

    Thanks in advance,

    Kalpana.

    Here you go

    Coding with Passion: Oracle ADF - Debug Mode object query with parameters

  • How to write the text file in Shockwave?

    Someone knows how to write the text file in Shockwave on the disc of the user?

    Thanks in advance.

    These Xtras can cause a lot of havoc when used with the intent to hurt.
    What you can do is to write with setpref and store a list of backups and the
    registers itself separately. Next, you need to build your own save/open
    dialog box for the user:
    * Choose a previously saved file to load or replace
    to create a user type the name of a new file to be saved.

    The only thing that remains is that the user can't decide where files
    are saved.

    Manno

    SiuLinda wrote:
    > Thanks a lot for your answer.
    > Yes, cookies is good, but I have to write a program to save the text file in
    > When the user wants, the user can open these files later if they like as, using
    > Filextra and Fileio, but I found that all these Xtra extensions seem to be not supported by
    > shockwave.
    >

    --
    ----------
    Manno Bult
    [email protected]

  • write the query sql for the following situation?

    We have a table like format following...

    A AND B
    ...................
    10 30
    50 40
    60 80
    90 100


    so to write the query and get the result like formats following...


    RESULT
    ............
    30
    50
    80
    100


    Try this... He's one of the interview question. I can't write the query...


    If a knowledge write the query...

    Hello
    Try this

    select (case when a>b then a else b end)   "Result"  from ;
    

Maybe you are looking for