Appending results returned by multiple queries into 1 row?

I have multiple select queries in a procedure. Each query processes different tables and returns one or two columns that need to be inserted to a staging table.
The results of these queries should be appended to one row.
select col1, col2 from table1 where......
select col3, col4 from table2 where....
Now the results of the above queries col1,col2, col3, col4 should be inserted to a temp table into one row as 4 columns.
How would I achieve this?

Thanks very much for everyone's help.
I am little confused. How would this fit in my queries. Please help me figure out how should I put these queries together.
SELECT
o.outageid,
et.Billlabor
FROM
emp_time et,
job j,
rate r,
vend v,
outage o,
outage_emp oe
where
j.jobid = et.jobid
and et.rateid = r.rateid
and r.vendid = v.vendid
and et.outage_empid = oe.outage_empid
and oe.outageid = o.outageid
group by
j.outageid
select
o.outageid,
count(e.empid) as empcount,
decode(o.outage_hrs, 0, 1, 0),
from
employee e,
outage_emp oe,
outage o,
outage_vend v
WHERE
e.empid = oe.outage_empid
and oe.outageid = o.outageid
and o.outageid = v.outageid
group by
o.outageid
select
o.outageid,
et.INTLABOR
from
emp_time et,
outage_emp oe,
outage o,
job j,
rate r,
vend v
where
j.jobid = et.jobid
and et.rateid = r.rateid
and r.vendid = v.vendid
and et.outage_emp_id = oe.outage_empid
and oe.outageid = o.outageid
group by o.outageid

Similar Messages

  • Inserting Multiple queries into a workbook

    Hi Friends,
    I have to insert multiple queries into a workbook and each query should be in a different worksheet of the work book.
    I have gone thru some of the SAP documentation, for example http://help.sap.com/saphelp_nw04/helpdata/en/3a/89883989676778e10000000a11402f/frameset.htm 
    In above link under the fatures section it says
    If you want to insert a query into the active workbook:
    Open a workbook and, from the BEx toolbar, choose Tools ® Insert Query.... The query is then inserted into the current worksheet starting at the active cell
    But when i chech in the tools under desig tools, i have lot of options like insert grid,insert checbox, radio button extc, but i dont have "Insert query".
    I am using BI7 Bex analyazer, The Only way i am able to insert a new query into a work sheet using BI7 is that first i have to design the work sheet but including design elemenst in my case i am using Grid. But this is not giving the correct display.
    Did anyone insert multiple queries in the same workbook? if you can you please let me know how did u acheive this?.
    Thanks in adv.
    Regards
    BN

    Hi Rajesh,
    Thanks for your response, but in BI7 Bex analyser you dont have the option of insert query from tools.
    Rather what i did is (maynot be the correct way), i have executed the query and saved it as work book and in the tools there is an option "copy Sheet". If you select this the same layout is copied to the 2nd sheet, there just change the assignment of design items to a new Dataprovider. Attach the new query to the new Dataprovider.
    It works for me, as of now
    But i have  questions regarding selection screen.
    1. In this work book i am embbeding 6 queries and each query individually has variables. When i execute the workbook i get the selection screen, in the selection screen all the common variables are shown in one grouping and other in a different grouping. Is this correct way of selection screen display?.
    2. I want to see the variable screen every time i open the work book, how can i acheive this?.
    Regards
    BN

  • Embedding multiple queries into a workbook in 7.0

    Hi,
    we are currently upgrading to 7.0 and I am really struggling to figure out how to embed mulitple queries into a single workbook.  The input query function no longer features on the Analyser toolbar.  Any help would be very much appreciated.
    Thankyou.

    We have a need to use the same query multiple times in the same workbook. Query results could be on separate pages, or on same page of the workbook.
    However, all of the results areas react to filtering and drilldowns done from any page and  the end result is that the all results are always the same on each page.
    Ideally, the first page would be a summary of all sales, then maybe the second would be a summary of product line sales, then the third to be a summary of customer sales.
    I know I can create new queries for each of these views, but there must be a better way. Has anyone discovered a method??

  • How to insert multiple queries into a single worksheet of same dataprovider

    Hello friends,
    My question is same as this.I want to know how to create a single worksheet(workbook) embedded with multiple queries of same DATA PROVIDER with different VARIABLES assigned to each query.
    Please,send me the relevant steps.
    Regards,
    Mohan Chand Reddy A

    Hi,
    You need to create one query workbook and rest of the queries you can insert manually from Bex tool -
    insert query.
    You need to insert query by adding one more tab in the workbook.
    Keep in mind only one thing that variable ..if you are going to keep variable it will keep on popping up for user entry in it.
    So try to have common variable in the first query and then those value needs to get fed into other query variable as they are running so without any user entry while execution we can see results in all the queries in the workbook.
    If you want to insert a query into a new workbook:
    Choose the symbol for Open...from the BEx toolbar. This brings you to the screen Open SAP BEx:
    Select Queries from the left column.
    Select a query from all those available. The queries are arranged according to InfoProviders.
    Double-click on the required query or choose OK.
    If you want to insert a query into the active workbook:
    Open a workbook and, from the BEx toolbar, choose Tools ® Insert Query.... The query is then inserted into the current worksheet starting at the active cell.
    If you want to insert a query into a workbook template:
    Create a workbook template.
    Insert the query into the workbook template.
    Thanks and regards
    Kiran

  • Using DATA_CELL and multiple queries into one table

    Hi WAD experts,
    I have been trying to work out how to combine multiple hidden query result sets in their own tables in the template, into one table displayed as if the data originated from one query.
    I have been looking at using the DATA_CELL method of "modify table" class.
    Has anyone had to do this before - and if so do you have any clues as to how best to do this ?
    Thanks
    Chris

    Here is what I want:
    Say I have a query that tells me about how many items were sold at a hardware store for each week. Then the output would look something like this:
    Week,Item,Num_Sold
    13,Hammer,15
    13,Nail,594
    13,Screw,398
    14,Hammer,16
    14,Nail,382
    14,Screw,331
    But I want my output to look like this:
    <space>,13,14 <-- these would be the week numbers
    Hammer,15,16
    Nail,594,382
    Screw,398,331
    I asked this same question in a SQL-only forum and one person responded that they did not know how to do that. But I figure that this is done often enough that there must be some Open Source program that can transform the output data into a table. As you can see, it's not a pure transform. It's more like I take one column, make that the x-axis, another column, make that the y-axis, and "plot" the data based on the two columns. It's kinda like taking 1D data and making it 2D. There's no existing open source program which does this? I figure that I could just give the program my SQL queries, specify some rule such as "Make the first column of the resultset the row, make the second column the column and create a table with the 3rd row, using the first two rows to map the 3rd row into the table". Note that I think this only works with 3 columns.
    Anyway, if there is no simple program that already does this, I can make a program to do what I just described. I just asked the question here because I figure that there are a lot of people knowledgeable about SQL and Java on this forum and that someone would know of a tool which already does what I want if one exists.

  • How to display results set of multiple reports into a single report table

    Our goal is to create a single report (or dashboard) that shows the "funnel" of object creations related to each campaign. The flow goes from Activity to Lead to Opportunity as well as multiple steps within each (ie. Unqualified Lead -> Qualified Lead, etc).
    We currently have 3 separate reports in three different subject areas, each reporting the different metrics and we would like to combine the output into a single Unified report.
    For example what we currently have is:
    Activities:
    Campaign Name # of Activities
    Campaign A 12
    Campaign B 26
    Leads:
    Campaign Name # of Leads # of Qualified Leads
    Campaign A 10 4
    Campaign B 20 18
    Opportunities:
    Campaign Name # of Opportunities # of Opps per Sales Stage ... # of Wins Closed Revenue
    Campaign A 3 2 1 $1,000.00
    Campaign B 10 8 3 $2,800.00
    What we want to see is:
    Combined:
    Campaign Name - Campaign Cost - # of Activities - # of Leads - # of Qualified Leads - # of Opportunities - # of Opps per Sales Stage - # of Wins - Closed Revenue
    Campaign A - $423.00 - 12 - 10 - 4 - 3 - 2 - 1 - $1,000.00
    Campaign B - $ 1,000.00 - 26 - 20 - 18 - 10 - 8 - 3 - $2,800.00
    We have tried using the "Combine with similar analysis" but the number of columns for each subject area differ. We also tried creating multiple UNION criteria (one for each column), but in the case of # of Opps per Sales Stage and Closed Revenue, those are not "Metrics" fields, so they won't combine.

    Hi, You may have to create some dummy fields to equate the no. of field in each of the report matching the data type too and get a one single report using combined analytics and then using the resultant data you can create a simple pivot like below. Haven't tried it before
    -- Venky CRMIT
    Hi Venky,
    I am facing the same problem. Can you please say Steps how to create resultant data and Combine in pivot Table .
    Please Help me .
    Thanks in Advance .
    My mail id is :
    [email protected]

  • Split multiple columns into rows using XML

    Hi Forum,
    I am trying to split 2 columns that each contain values separated by semicolon into single rows. The relation between the values of the two columns is that the order in the cells corresponds to each other.
    The data looks like this:
    pk    Manufacturer                partnumber
    1     Man1; Man2;Man3      PN1;PN2;PN3
    2     Man4; Man2;Man5      PN4;PN5;PN6
    The result should be:
    pk    Manufacturer     partnumber
    1       Man1                   PN1
    1       Man2                   PN2
    1       Man3                   PN3
    2       Man4                   PN4
    2       Man2                   PN5
    2       Man5                   PN6
    I am not sure how to format the XML to get a useful Basis for XML.value or XML.query
    Any ideas?
    TIA
    Alex

    Hi,
    Try like this ,
    DECLARE @tmp TABLE (pk INT,Manufacturer NVARCHAR(50),partnumber NVARCHAR(50))
    INSERT @tmp SELECT 1,'Man1; Man2;Man3','PN1;PN2;PN3'
    INSERT @tmp SELECT 2,'Man4; Man2;Man5','PN4;PN5;PN6'
    SELECT * FROM @tmp
    SELECT tmp2.pk pk,Manufacturer,partnumber FROM (
    SELECT ROW_NUMBER()OVER(ORDER BY tmp1.pk) RN,* FROM (
    SELECT pk,
    LTRIM(i.value('.','varchar(100)')) Manufacturer
    FROM ( SELECT pk, Manufacturer,
    CONVERT(XML,'<r><n>'
    + REPLACE(Manufacturer,';', '</n><n>') + '</n></r>') AS X
    FROM @Tmp) Spt
    CROSS APPLY Spt.X.nodes('//*[text()]') x(i)
    ) tmp1 ) tmp2
    JOIN
    (SELECT ROW_NUMBER()OVER(ORDER BY pk) RN,* FROM (
    SELECT pk,
    j.value('.','varchar(100)') partnumber
    FROM ( SELECT pk, partnumber,
    CONVERT(XML,'<r><n>'
    + REPLACE(partnumber,';', '</n><n>') + '</n></r>') AS Y
    FROM @Tmp) Spt
    CROSS APPLY Spt.Y.nodes('//*[text()]') y(j)) tmp2 ) tmp3 ON tmp3.RN = tmp2.RN
    sathya - www.allaboutmssql.com ** Mark as answered if my post solved your problem and Vote as helpful if my post was useful **.

  • BEX Workbook - consolidating common data from multiple queries into a table

    Hello BW Gurus,
    We have couple of queries. One getting data for Material and its components and the other query getting sales volume for  material along with many other data.
    In the other tab, I would like to display only the Material and its sales volume as another table.
    Is there a setting in the BEX to group only these fields and populate values in a different tab?
    regards
    S R

    Can you pls elaborate?
    Do you want multiple reports on single excel sheet? also do you want to have any relation between them like only those materials that appeared in first report?

  • Form results return to multiple recipient

    Is there a way of allowing forms to return the collected information to multiple recipient?
    I would love if anyone could point me in the right direction.
    Thanks a mil

    You could build a process using Workbench that uses Forms and then send the information to multiple participants.
    Jasmin

  • How to combine multiple queries!

    I know this is pretty basic, but I'm confused. Basically, I need to extract all data for a given entity from a highly normalized database. There are probably 2 dozen tables which contain data for a given entity that must be queried. However, rather than constructing one single query that merges all of the tables together to come up with one huge rowset/row format, how could I query each table seperately and combine the results of each query into one XML file? Can I create a clob with the first query and then append subsequent queries to that clob? Not sure what to do, and I can't find any good examples.
    Thanks in advance!

    Thanks, but I don't think that's quite what I'm looking for. In a nutshell, this is what I'm doing and this is the problem I'm having:
    1. I set a string equal to a query.
    2. I use xmlgen.getxml to fetch the xml into a clob.
    3. I parse the clob into a DOMDocument.
    The problem occurs with multiple queries. If I follow this same process for 5 different queries, then I have 5 instances of a DOMDocument, each holding a different queries XML. Now, can I put them together? I tried xmldom.makeNode for each DOMDocument, but the nodes are associated with the Document from which they came. I tried cloning each node to disassociate from it's Document, but that didn't seem to work. Even if it did, and I got all of the nodes together, I kept getting a java.lang.ClassCastException for trying xmldom.makeDocument for a node. I'm lost. How can I combine the results of multiple queries into a single DOMDocument instance? It was suggested that use xmlgen.getXML to get multiple queries into multiple CLOBS, then essentially combine the CLOBS together, and finally parse into a DOMDocument as a last step, but that doesn't really leverage DOMs capabilities. At this point, I may have to go down that road...

  • Insert multiple queries using either WORKBOOK, WAD or Report Designer

    Hello Guys
    I have a task where I have to insert multiple queries into one single page/sheet & print it out later. For this I can use any one of the tools available: Workbook, WAD or Report Designer.
    1. Workbook - Here I have read that we can use a call back MACRO and some other features.
    2. WAD - Here I have read that we can use: 1. Multiple data providers (one for each query) & 2. Multiple web analysis items linking to each individual data provider.
    3. Report Designer - Since this is the actual 'formatting' tool provided by SAP, I am assuming that this is the right environment to achieve my task.
    My question: Which one out of the above 3 tools is actually feasible? Can someone explain me in detail about how to go about this task. Any 'How to..' docs from SAP would also be most helpful.
    Regards.

    Hi Kashyap,
    I have done similar requirement in Workbook,it has better features and more user friendly than others......it depends on the individual...but U cna meet your requirement thru Workbooks...
    If the Req are complicated then we go for MAcros ,where in we can satify the critical req,say some sort of Dynamic reqs.
    There are lot of threads on Multiple queries in one Workbook....Just search in SDN and u will get lot of Threads on this topic.
    Come bak if u have any other doubts.
    Rgds
    SVU123

  • Result may contain single string or comma separated need to split into rows

    Hi, All... I've searched through the forums and found plenty on splitting comma separated into rows; though I'm struggling applying it to my situation. I have data that looks like the below where I need to split a value into multiple rows if it should be but the same field in the table may also contain a string that should not be separated (indicated by the "Array" field being 0 or 1)...
    WITH t AS
    (SELECT 1 as array, '"Banana", "Apple", "Pear"' as str FROM dual union all
    SELECT 0, 'Fruit is delicious' FROM dual union all
    SELECT 0, 'So are vegetables' FROM dual union all
    SELECT 1, '"Bean", "Carrot", "Broccoli"' FROM dual union all
    SELECT 1, '"Apple", "Banana"' FROM dual)I've looked through many of the connect_by posts on the forum and I haven't come across one that splits a field if it should be but doesn't if it should not be... may have missed it because there are plenty of these requests on the forum!
    If you're feeling even more ambitious - the ultimate goal is to count the number of times a particular answer appears in an array - so notice the last portion of the data contains "Apple", "Banana"... the result would show:
    RESULT
    Banana             2
    Apple              2
    Pear               1
    Bean               1
    Carrot             1
    Broccoli           1
    Fruit is delicious
    So are vegetablesI can always sort them later based on other fields in the table - but the result above would be my ultimate goal!
    Any help is always appreciated. Thanks! 11g

    Hi,
    The examples you found should work for you. Just use a CASE expression to determine if str needs to be split or not, by looking at array.
    Here's one way:
    WITH     got_part_cnt     AS
         SELECT     array, str
         ,     CASE
                  WHEN  array = 0
                  THEN  1
    --              ELSE  1 + REGEXP_COUNT (str, '", "')     -- See note below
                  ELSE  1 + ( ( LENGTH (str)
                                  - LENGTH (REPLACE (str, '", "'))
                         / 4
              END          AS part_cnt
         FROM    t
    ,     cntr     AS
         SELECT  LEVEL     AS n
         FROM     (
                  SELECT  MAX (part_cnt)     AS max_part_cnt
                  FROM    got_part_cnt
         CONNECT BY     LEVEL     <= max_part_cnt
    ,     got_sub_str          AS
         SELECT     CASE
                  WHEN  p.array = 0
                  THEN  p.str
                  ELSE  REGEXP_SUBSTR ( p.str
                                   , '[^"]+'
                             , 1
                             , (2 * c.n) - 1
              END     AS sub_str
         FROM     got_part_cnt  p
         JOIN     cntr           c  ON  c.n <= p.part_cnt
    SELECT       sub_str
    ,       COUNT (*)     AS cnt
    FROM       got_sub_str
    GROUP BY  sub_str
    ORDER BY  cnt          DESC
    ,            sub_str
    {code}
    The only database at hand right now is Oracle 10.2, which doesn't have REGEXP_COUNT.  I had to use a complicated way of counting how many times '", "' occurs in str in order to test this in Oracle 10.  Since you have Oracle 11, you can un-comment the line that uses REGEXP_COUNT in the first CASE expression, and remove the alternate ELSE clause (that is, the next 5 lines, up to END).
    To make sure that this query is really paying attention to array, I added this row to the sample data:
    {code}
    SELECT 0, '"Bean", "Carrot", "Broccoli"' FROM dual union all
    {code}
    Even though str looks just like a delimited list, array=0 tells the query not to split it, so it produces these results:
    {code}
    SUB_STR                               CNT
    Apple                                   2
    Banana                                  2
    "Bean", "Carrot", "Broccoli"            1
    Bean                                    1
    Broccoli                                1
    Carrot                                  1
    Fruit is delicious                      1
    Pear                                    1
    So are vegetables                       1
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Iterating through the result of a multiple row sql statement

    Hi all,
    I would like to access the results of a multiple row sql-statement. However I can't find out how to do this, can you help me here?
    I have tried using the "node-set" functions in xpath, but I can't seem to get it right.
    How should I approach this scenario?
    Sincerely
    Kim

    The jdbc service has the option of returning xml back to you ...if you do it this way then you can interogate the xml

  • Problem with the result of multiple queries in Web Intelligence (BO XI R2)

    We have a problem with Web Intelligence reports. Behavior of the results is like if we selected the function Count in Designer the properties indicators. Same queries separated one for one report give correct results and together 7 queries in one report give correct results only for the first query and for others (6 others) same results for each date (if report is monthly) or the same result for each hour (if the result is daily) for all Queues tested (other which were not tested have result 0). Even the function Sum inserted into the report structure behaves weird u2013 we have the same result as in the filed (it is a copy of that result, not a sum). We tested queries together in SQL Developer and they give correct results, while in BO big query which contains script from Query 3, Query 2  and Query 1 cannot be completely executed (it executes without end).
    We use Business Objects XI R2 SP3.
    Thanks in advance.

    Hi Peter,
    I guess it is the problem due to the merged dimension and different granurality level in the BO queries. From the document properties uncheck the option of auto-merge common dimension objects or manually unmerge all the common dimensions
    than give it a try.
    I guess this would solve your problem. If not can you provide more query details like what objects you have used in the query.

  • How to using one HTTPService to handle multiple result returns

    I have a HTTPService class that handles one fault and one result events. Is there a way to the same HTTPService to handle more than one result returns.
    For example, to handle Result1, Result2, ... events with different Listeners: Listener1, Listerner2, ...

    My approach would be to include the logic necessary to handle the possible results in my result handler. The result handler receives the ResultEvent and the logic conditionally executes based on the result returned.

Maybe you are looking for

  • ICal doesn't show all text for the activity

    When I updated to iCal version 8.0 i noticed that when I am in week-view, iCal doesn't show all the text for an activity, although there is plenty of room. For example I have a lecture from 9 am - 4 pm and in the activity I put down all the things I

  • Hp v40 on xp desktop and is shared via wireless network. laptop with windows 7 wont print on v40.

    Can't print from laptop (windows 7) via wireless router .to desktop (windows xp) with usb attached HP v40 all in one. Laptop (7) ----- wireless router ----- desktop (xp) - -usb-- HPv40 Worked when laptop was running xp. Laptop spools print job to des

  • How to modify Find and Change indicator?

    I use Find and Change in Applewors 6. At present, this operation finds what is specified but the indicator is colored green and is open, and hard to locate on a page when looking for a single letter. I changed it from its original pale orange to what

  • Mp4 to DVD in Compressor, aspect ratio

    I'm trying to make a DVD of an mp4 movie I have. I put it in Compressor and chose DVD best quality 150 minutes (since it's over 2 hours) and I made sure the aspect ratio was 2.35:1 since that's what the movie is. It plays fine in the preview window i

  • Adobe Reader 10.0.1 - error 1606

    I am reveiving error "1606 Could not access network location %APPDATA%\.. I have attempted to uninstall (to reinstall) and I am receiving the same error message. Not sure what to do, I work from home and can't open any PDF files! Please HELP!! Kari