output from two different queries as a result

Hello

I want to run a query or a field provided that I want to see the result in 2 areas

1st request

SELECT ALL CANWORKORDER. WORKORDERNO, SUM (CANPTN. PTNQTY PTNQTY), MIN (CANPTN. NSO NSO) OF CANWORKORDER, CANPTN

WHERE CANWORKORDER. PENDINGQTY > 0

AND (CANWORKORDER. WORKORDERNO = CANPTN. WORKORDERNO) and canworkorder.pendingqty > 0

and canptn.fgstat IS NULL

GROUP OF CANWORKORDER. WORKORDERNO

2nd request

SELECT ALL CANWORKORDER. WORKORDERNO, SUM (CANPTN. PTNQTY PTNQTY), MIN (CANPTN. NSO NSO) OF CANWORKORDER, CANPTN

WHERE CANWORKORDER. PENDINGQTY > 0

AND (CANWORKORDER. WORKORDERNO = CANPTN. WORKORDERNO) and canworkorder.pendingqty > 0

and canptn.fgstat IS NULL

GROUP OF CANWORKORDER. WORKORDERNO

How can I join both the query and get a single query output.

1 PTNQTY, WHERE FGSTAT IS NULL

2 PTNQTY, WHERE FGSTATUS IS NOT NULL

Structure

create the workorder table

number of workorderno

fgstatus varchar2 (1))

create table (MNR)

number of workorderno

number of mrnqty)

create table (ptn)

number of workorderno

number of mrnqty)

create table status)

number of workorderno

number of mrnqty

number of ptnqty

number of processqty)

Sandy

Hello

2 queries that you posted look identical to me. Probably one of them should have the condition

and canptn.fgstat is NOT null

It is not useful to also post the CREATE TABLE without insert statement.

Last but not least please post results in a clearer way.

I guess you want to have 2 different values (with fgstat NULL and FGSTAT not null in 2 different columns in the same row):

select canworkorder.workorderno
     , sum (case when canptn.fgstat is null then canptn.ptnqty end) ptnqty_fgstat_null
     , sum (case when canptn.fgstat is not null then canptn.ptnqty end) ptnqty_fgstat_not_null
     , min (canptn.ons) ons
  from canworkorder, canptn
where canworkorder.pendingqty > 0
   and (canworkorder.workorderno = canptn.workorderno)
   and canworkorder.pendingqty > 0
group by canworkorder.workorderno;

In case you need a different output please post some samples.

Kind regards.

Alberto

Tags: Database

Similar Questions

  • Reports from two different domains

    Hi all

    Is it possible to account for two different subjects areas, i.e., a report that contains fields from two different areas? If so, how could we select fields from two different disciplines in a single report of responses?

    Thank you!!

    One thing to understand is that if you're imagining having two areas (SAs) poster and then by dragging the columns of each in your application without any preparation, then no, that cannot be done. You would need to make a join in the MDB layer and expose the column of the second subject area in the presentation layer.

    But if you indeed interested in UNION (or cross) queries, then do this:

    Build your first application in the first SA in the usual way. Note the number of columns and the data types of each column.

    Now at the bottom of the workspace of criteria, there is a button called "Combined with application similar." Until it clicks.

    Select your second. You will notice that the contours of the columns in your first query appear. This is to remind you that the number of columns in this second query must be the same as in the first. It also shows the data type of each column for the same reason.

    Once you select your columns and your filters, click result. (Oh, you need to decide what kind of combination you want - click the menu drop down.) The result will be a new application that has data from two SAs in the query and combined in the way you select (union, intersection, etc.)

    This should give you a start.

    They are now, some 'useful' or 'correct' points for users on this thread...

  • To find common data in 2 columns from two different tables.

    Hello

    Could someone help me with a querry to discover common data of 2 columns from two different tables?

    Thank you
    Rajesh

    Try as below.

    select col1 ,col2 from tab1
    intersect
    select col1 ,col2 from tab2;
    
  • How to synchronize files from two different subscriptions in two different Office CC files

    Hello

    I have two subscriptions for CC, work and staff. I ran the subscription of work in two computers at work and at home (when I need to work from home.) The problem I find, is that there are not two different folders to CC for each subscription. When I connect from my subscription to work, all my files from this subscription disappear. Then when I connect again, they all synchronize the process starts again. I chose to have two different subscriptions in order not to mix my personal work of my work. Is it possible to have a CC folder on my desktop for each subscription? In this way, when I log out of an account and switch to the other files of the account that I just connected not replaced for the files in the account in that I just signed.  Help with this will be greatly appreciated.

    Hello

    I just want you know what you should see when using 2 accounts.

    An account:

    1. connect with Adobe ID account

    2. synchronization of files to files creative cloud, which is located in your home directory on Mac or Windows.

    3 newspaper account one, creative Cloud now displays the log in the Panel.

    Two account:

    1. connect with Adobe ID account two

    2. synchronization of files creative Cloud account 2 which is located in your home directory on Mac or Windows. (His Creative Cloud Files account folder is called re)

    Things to check are:

    After you connect to account for two, creative cloud to account 1 file should be renamed, can you check this please make sure there.

    The same is true are you connect again to an account, record of the creative cloud has two will be renamed.

    The data should not have fully re - never synchronize when you open a session on the account 1 and account 2 then, however, can you be sure that the data is actually re download. That is to say; you had 5 GB of data in one account and when you log in account 1 whole 5 GB of data is re download?, could check you this?

    The creative files Cloud Panel will display "Synchronization" for a short time while change you account is, it's normal, and means the application reads data on disc and on the server of checking for changes / added files etc. This isn't re - download all your data, it is simply a check.

    You are able to move the creative cloud files folder to any location on your hard drive via the preferences of creative cloud.

    Thank you

    Warner

  • Is it possible to have the audio from two different sources and routed to separate outputs at the same time?

    I currently have a string of the guitar signal electric-Rocksmith Real Tone cable - ASIO 4 all help IK Multimedia Amplitube 3.   I would like to know if I could also watch DVD with her while the implementation of the programme of Amplitube with sound.  It would be great that I use the DVD for guitar and play at the same time.   I don't have the signal of two merged as one.  In my mind, I should be able to disable the ASIO devices and use them with DirectX as usual.  I could send the ampitube signal to the headphones and use external speakers for the guitar signal, and use the lessons of speakers for the DVD (or maybe YouTube) laptop on board.

    Is this possible?

    How can I do?

    Toshiba Satellite X 205-S7483

    Jeff

    Yes.  For example, I have my Skype phone calls go to my helmet (normal just plugged in the headset) while my media player plays my speakers.  You can choose your default communication or multimedia devices with a right click on the volume control icon and choosing "playback devices".

    Other programs can also be built to be "to the output current" and allow you to choose the output too.

  • How to synchronize the analog input and the output of two different USB data acquisition boards

    Hi all

    I have two tips very different USB NI USB 6008 case, which I use to acquire the data (analog input) and a USB of NI 9263 is a output analog only site I use to route a signal (in this case a square pulse). The reason why I use the outputs analog 6008 is because I need to deliver negative tension and need the full +/-10 v range.

    Looking at similar positions, I'm pretty sure that I can't use an external trigger or a common clock, I also tried to use the timed synchronization of the structures but no cigar.

    I'm including a quick vi I whipped showing how the jitters because of the lack of synchronization signal. The OD of the 9263 connects to AI in the 6008 in this example.

    I talked to a specialist in the phone and tols me that's not possible.

  • I want to loop through the data from two different tables using for loop where the query should be replaced at runtime, please help me

    I have the data into two table with the structure of similar column, I want to loop through the data in these two tables

    based on some condition and runtime that I want to put the query in loop for example, the example is given, please help me

    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

    declare

    l_statement varchar2 (2000);

    Boolean bool;

    Start

    bool: = true;

    If it is true, then

    l_statement: =' select * ab ';

    on the other

    l_statement: =' select * from bc';

    end if

    I'm in execute immediate l_statement - something like that, but I don't know

    loop

    dbms_output.put_line (i.a);

    end loop;

    end;

    Something like that, but this isn't a peace of the code work.

    Try this and adapt according to your needs:

    declare

    l_statement varchar2 (2000);

    c SYS_REFCURSOR;

    l_a number;

    l_b varchar2 (20);

    Boolean bool;

    Start

    bool: = true;

    If it is true, then

    l_statement: = "select a, b, AB;

    on the other

    l_statement: = "select a, b from bc;

    end if;

    --

    Open c for l_statement;

    --

    loop

    extract the c in l_a, l_b;

    When the output c % notfound;

    dbms_output.put_line (l_a |') -' || l_b);

    end loop;

    close c;

    end;

    /

  • Passage of a setting for two different queries on a single page

    I followed tutorial ADF - value of the parameter passing between Pages. It works very well, but I tried to add a second query to the page single.jspx , using the same setting and it shows all the data.

    I tried to analyze the queries and the problem is in bind variables. While the first query gets the right value, the second Gets null (see the log below). I also noticed that if I return to the single.jspx page, only the first request is executed.

    < oracle.adf.model > < ViewObjectImpl > < buildQuery > < [3556] SELECT ServiceRequests.ASSIGNED_DATE,.

    ServiceRequests.ASSIGNED_TO,

    ServiceRequests.CREATED_BY,

    ServiceRequests.PROBLEM_DESCRIPTION,

    ServiceRequests.PROD_ID,

    ServiceRequests.REQUEST_DATE,

    ServiceRequests.STATUS,

    ServiceRequests.SVR_ID

    OF SERVICE_REQUESTS ServiceRequests

    WHERE (ServiceRequests.SVR_ID =: p_svr_id) >

    < oracle.adf.model > < ViewObjectImpl > < getPreparedStatement > < ViewObject [3557]: [oracle.srdemo.model.ServiceRequestById_VO] AppModule.ServiceRequestById_VO1 created new QUERY statement >

    < oracle.adf.model > < ViewObjectImpl > < bindParametersForCollection > < [3558] params for ViewObject Bind: [oracle.srdemo.model.ServiceRequestById_VO] AppModule.ServiceRequestById_VO1 >

    < oracle.adf.model > < OracleSQLBuilderImpl > < bindParamValue > < [3559] param 'p_svr_id' liaison: 111>

    < oracle.adf.model > < ViewObjectImpl > < buildQuery > < [3716] select svh_date, service_histories where svr_id =: p_svr_id order of svh_date >

    < oracle.adf.model > < ViewObjectImpl > < getQueryHitCount > < [3717] number of rows estimated for ViewObject: [oracle.srdemo.model.ServiceHistoryByRequestId_VO] AppModule.ServiceHistoryByRequestId_VO1, query statement: >

    < oracle.adf.model > < ViewObjectImpl > < getQueryHitCount > < [3718] ' SELECT count (1) FROM (select svh_date, notes from service_histories where svr_id =: p_svr_id order of svh_date) ">"

    < oracle.adf.model > < ViewObjectImpl > < getQueryHitCount > < [3719] Bind params for ViewObject.getQueryHitCount: ServiceHistoryByRequestId_VO1 >

    < oracle.adf.model > < ViewRowSetImpl > < doSetWhereClauseParam > < [3720] ServiceHistoryByRequestId_VO1 ViewRowSetImpl.doSetWhereClause(-1, p_svr_id, null) >

    < oracle.adf.model > < OracleSQLBuilderImpl > < bindParamValue > < [3721] null of type 12 for connection "p_svr_id" > ""

    I got it.

    I need to add an another ExecuteWithParams of the request on the other in the pageflow.

  • Fill in the select list with two different queries depending on the user's group

    Hello

    I finished my first production application using apex. I have a Select list that takes its values from a sql query. Now, I want this different query for each user based on the group. Basically each user sees only the projects they are responsible - that works fine. But I want all the people of the admin group to see all the projects - how can I do this?

    Thank you very much!!!
    Henrik

    Hello

    Try this

    SELECT s.caption || ' - ' || s.sapnr display_value
          ,s.sharedservice_id return_value
    FROM   sharedservices s, sharedservicelead l
    WHERE  (   s.sharedservicelead_id = l.sharedservicelead_id
            OR s.ssldeputy_id = l.sharedservicelead_id
           )
    AND    l.username = :app_user
    UNION
    SELECT s.caption || ' - ' || s.sapnr display_value
          ,s.sharedservice_id return_value
    FROM   sharedservices s
    WHERE  HTMLDB_UTIL.get_groups_user_belongs_to(:APP_USER) = 'capacitymanagement'
    

    See you soon

    Ben

  • How to extract elements from two different descriptors-point?

    Hi all

    I have a requirement for all elements of trade based on a property in the trade section and order status should be presented.

    Status of the order is in order and trade item to the article of commerce property.

    is it possible to ask about two descriptors of the order of the day, if possible, please provide a solution as soon as POSSIBLE.

    Thanks in advance

    You only need commerceItems based on a trade item property and a property of the order. as referential point trade point has the associated command point reference thats why it is feasible with the POOR. You should search the descriptor CommerceItem point OrderRepository. Your POOR query would be like yourcustomProperty is equivalent to "xyz" AND Decree. Status equals "SUBJECT"

  • Navigate from two different master on the same page of detail pages

    Hello. IM using JDev 11.1.1.1.0 JDEVADF_11.1.1.1.0_GENERIC_090615.0017.5407. Fusion Web application.

    I have two ViewObjects based on an entity unique entity1 and each VO has another value where clause. First, I create a master VO1-based view and a page of details based on the same VO1. Navigation works very well using a link in the pharmacokinetics of the selected line and using setCurrentRowWithKey.

    Then I created a view of second master page based on VO2 and to enable navigation to the page of detail based on VO1. I thought that the key is the same (entity has a PK a column and the same VO1 and VO2) but when I tried browsing with setCurrentRowWithKey or setCurrentRowWithKeyValue does not work.


    Can anyone provide steps to achieve this? Is it possible to do?

    Thank you.

    Hello

    You might be using the method setCurrentRowWithKey of VO2, if so, try to use the method setCurrentRowWithKey VO1 (on which detail page is based)

    Jean Lou

  • Concatenate the date and time that are stored in two different date columns

    Hello

    I have to select date two columns from two different tables a date and another over time.

    I want to concatenate these two columns and format the result form dd/mm/yyyy hh24

    But I get error invalid number

    For example

    create table as datetime

    (select to_date (' 21/01/2014 ',' dd/mm/yyyy') as dt, to_date('08:00','hh24:mi') like double MC

    )

    Select to_char(dt||) TM, "dd/mm/yyyy hh24") of datetime

    I use oracle 10 g

    Help, please.

    Hello

    Roger wrote:

    ... If you need to take the party date to a date column and the time of anonther part, then you must first convert them to a string, concatenate them and convert them to date.

    You don't need to do this.  What you have described is a way to do it, but this isn't the only way.

    If d1 and d2 are the two DATEs, you can get year, month and day of d1 combined with hours, minutes, and seconds from d2 liike this:

    TRUNC (d1) and (d2 - TRUNC (d2))

    Nesting TO_DATE and TO_CHAR in Oracle, is almost never the best way to do anything.  Oracle provides many functions (for example, TRUNC) to manipulate dates, but also of DATE arithmetic.

  • Process in two different tables in one page

    Hi all

    I have A form with a submit button, when I click on the button I want to send the data from two different tables. For example:

    REQ_ID: 221

    BOX_NUMBER: 2

    NOM_ELEMENT: APPLE

    COUNTRY_ORIGIN: USA

    I want to send all the information in table 1 and only REQ_ID and BOX_NUMBER in table 2.

    I tried to create processes two different which are:

    1. the usual process line DML for table 1 and;

    2. simple query 'Insert' SQL for table 2

    It seems fine, until I realized that when the user tries to update the BOX_NUMBER to 10 for example, only 1 table is updated and table 2 creates an another duplicate data instead of updating the old one! This also applies to my button Delete,.

    any idea to fix this problem?

    Thank you very much

    Vika

    Reread what you wrote and you would realize why 2nd table only "new lines".

    2. simple query "Insert into ' SQL for table 2

    If you need to UPDATE the table, then you must write a simple UPDATE statement.

    If you want to REMOVE from the table, then you must write a simple DELETE statement.

    I call this "DML DIY" - do it yourself DML

    (personally, I'd probably use MERGE for INSERT and UPDATE)

    MK

  • extraction of unique records of registration of two different tables

    Hello

    In the following two tables different www.testing.com code exists in both tables. I want to compare two different columns from two different tables for unique records.
    SQL> select unique(videoLinks) from saVideos where sa_id=21;
    
    VIDEOLINKS
    -----------------------------------------------------------------------
    www.testing.com
    
    SQL> ed
    Wrote file afiedt.buf
    
      1* select unique(picLinks) from saImages where sa_id=21
    SQL> /
    
    PICLINKS
    -----------------------------------------------------------------------
    test
    test14
    www.hello.com
    www.testing.com
    Thank you and best regards

    Try
    Select unique (videoLinks) in the saVideos where sa_id = 21
    Union
    Select unique (picLinks) in the saImages where sa_id = 21

  • How to get data in two different bases?

    Hello guys!

    I want to retrieve data from two different databases. I can't use one because they are in different cities, and now I need to use both. How can I do?

    Thank you!

    Published by: Tipertuba on 11/11/2009 05:13

    Use the links in DB, if everything you do is querying the data... if its replication in time more real then look in or data streams keep... but below you can find things on the database link

    http://www.morganslibrary.org/reference/Db_link.html

Maybe you are looking for