Trying to create single select from two

Hi all, i am new to this forum so be gentle with me...;-)
i have got the following two queries that group by a number of columns and return counts of the grouped columns....now the question is, can i get a single query out of this with the two counts still coming out as two seperate counts but all grouped together...any advice gratefully received...
1)
SELECT BUSINESS_EVENT_DATE,
     nvl(POS_TYPE,'NONE') POS_TYPE,
     nvl(APPLICATION_TYPE, 'NONE') APPLICATION_TYPE,
     nvl(PROCESSING_AREA, 'NONE') PROCESSING_AREA,
     COUNT(*) APPS_RCVD
FROM APPLICATION_FACT
GROUP BY BUSINESS_EVENT_DATE, POS_TYPE, APPLICATION_TYPE, PROCESSING_AREA
2)
SELECT AF.BUSINESS_EVENT_DATE,
     nvl(AF.POS_TYPE,'NONE') POS_TYPE,
     nvl(AF.APPLICATION_TYPE, 'NONE') APPLICATION_TYPE,
     nvl(AF.PROCESSING_AREA, 'NONE') PROCESSING_AREA,
     COUNT(*) APPS_WITH_ANCAS_RCVD
FROM APPLICATION_FACT AF, APPLICATIONWARNING_FACT AWF
WHERE AF.INTERNAL_ACCOUNT = AWF.INTERNAL_ACCOUNT
AND AF.APPLICATION_SEQ = AWF.APPLICATION_SEQ
GROUP BY AF.BUSINESS_EVENT_DATE,
          AF.POS_TYPE,
          AF.APPLICATION_TYPE,
          AF.PROCESSING_AREA

Hello
I think you need to look at UNION and UNION ALL:
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/queries5a.htm#2054266
HTH
David

Similar Messages

  • Creating Single TreeTable from two self linking VOs

    Hi,
    Lets say, I want to show the organization structure in TreeTable in following format
    NOTE: I am sorry, I am not able to get the indentation. Every row in below layout is indented one level compared to above row
    Continent
    Country
    AreaHead
    Employees
    So the layout should look like
    Asia
    India
    Ahead01
    Emp01
                   Emp02
    Below are the tables I am using
    1. LOCATION – Self linking table which displays continents and countries hierarchically.
    Eg:
         | Location | Location_ID | Parent_Location_ID |
         | India | 100 | 101 |
         | Asia Pacific | 101 | 102 |
    2. EMPLOYEE Table – Employee table which holds employee details
         Its a self linking table which defines manager, team member relationship
         Holds a foreign key to LOCATION table
         | Employee_ID | Name | Designation | Location | Manager_ID |
         | 100 | Emp01 | Area Head | 100 | |
         | 101 | Emp02 | Department Head | 100 | 100 |
    I have created two VOs LOCATION, EMPLOYEE and two self referencing view links
         one on LOCATION.LOCATION_ID to LOCATION.PARENT_LOCATION_ID
         one on EMPLOYEE.EMPLOYEE_ID to EMPLOYEE.MANAGER_ID
    While displaying as a tree table the details of EMPLOYEE table should start from the leaf node of LOCATIONS table.
    Please let me know the best way of achieving this. I am okay with creating a VO programatically accessing other VOs?
    I am using JDeveloper: 11.1.1.3.0
    Edited by: 817895 on Dec 5, 2010 6:06 AM
    Edited by: 817895 on Dec 5, 2010 6:13 AM

    Hi,
    see sample 32 on http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html
    Frank

  • Select from two tables and insert into a third

    I'm trying to do a select from two tables and do an insert into a third table from the two resulting columns.
    I have the following....
    DECLARE
    tempsid number;
    temphostid number;
    BEGIN
    select "DBSID_ID","ID" into tempsid,temphostid from "DBSIDS","SERVERS"
    where "HOST_SID" like '%'||"DBSID_NAME"||'%'
    and "HOST_NAME" not like 'vio%'
    and exists (select "DBSID_NAME" from DBSIDS)
    order by "DBSID_NAME";
    insert into "DBSID_LOOKUP" ("SIDLOOKUP_ID", "SERVERLOOKUP_ID")
    values(tempsid, temphostsid);
    END;
    run;
    I get the error ....
    ORA-06550: line 11, column 18:
    PL/SQL: ORA-00984: column not allowed here
    ORA-06550: line 10, column 1:
    PL/SQL: SQL Statement ignored
    1. DECLARE
    2. tempsid number;
    3. temphostid number;

    okay ... I tried a different way ...
    DECLARE
    a number;
    b number;
    BEGIN
    select "DBSID_ID","ID" into a,b from "DBSIDS","SERVERS"
    where "HOST_SID" like '%'||"DBSID_NAME"||'%'
    and "HOST_NAME" not like 'vio%'
    and exists (select "DBSID_NAME" from DBSIDS)
    order by "DBSID_NAME";
    insert into "DBSID_LOOKUP" (SIDLOOKUP_ID, SERVERLOOKUP_ID) values (a, b);
    END;
    and now it whines about ...
    ORA-01422: exact fetch returns more than requested number of rows

  • Selecting from two tables and confirming from them despites they not relate

    Please I need a query to select from two tables that are not related to each other.
    I also want to confirm data's as in verify wether what the user has entered is in accordance with what is in the tables
    Examples
    the first table is named "Card" and the second table is named "Student_Details"
    Card table contains a column named "Pin_Number".
    The Student_Details table contains fields such as Exam_Number, Name, Age, Sex.
    The user has to Enter the Pin_Number which has to be confirmed in the Card table and Exam_Number which has to be confirmed in the Student_Details table and verify that both data's are correct.
    Please I need the SQL and PL/SQL queries for this problem.
    Thanks

    Hi,
    I think you need two different queries
    You can write a procedure like:
    create or replace procedure p1 (p_pin_number number, p_exam_number)
    is
      r_card_row            card%rowtype;
      r_student_details     student_details%rowtype;
      cursor c1 is
      select *
        from card
       where pin_number = p_pin_number;
      cursor c2 is
      select *
        from student_details
       where exam_number = p_exam_number;
    begin
      open c1;
        loop
          fetch c1 into  r_card_row;
          exit when c1%notfound;
          ....  do whatever you want..... and the samething you can do with other cursor
        end loop;
      close c1;
    end p1;Hope this helps
    Ghulam

  • Selecting from two tables but making it just one selection

    Is there a way to select from two tables and just have one selection appear?
    Specifically I have a fact_install_unit, and a fact_install_arch table.
    Sometimes the value exists in fact_install_unit.factory_timestamp, and sometimes when fact_install_unit.factory_timestamp is null I need to pull it from the fact_install_arch.factory_timestamp.
    sort of like:
    (select fact_install_unit.factory_timestamp
    from fact_install_unit, fact_install_arch
    where fact_install_unit.fl_unit_sak = fact_install_arch.fl_unit_sak
    and where fact_install_unit.factory_timestamp is null then display fact_install_arch.factory_timestamp)

    > I was just stating that I do not have sufficient priveleges to create views in this database.
    >
    nm means "no more" than that
    And how are we supposed to know that? You seem to have changed the thread subject to "unfortunately I only have read-only and insufficient priveleges", which is not even a question.
    nm means "New Mexico":
    http://www.myshortpencil.com/schooltalk/messages/85/515.html?971794944

  • In iPhoto 11 trying to create a book from an album.

    Trying to create a book from album in iPhoto 11.  The photos in the album were manually sorted to be in the order I want.  When I select the album as the source for the book the pictures are re-aranged and placed in a different order.  How do I use the album as the source for the book and keep the pictures in the order I placed the album in?

    I found an solution in and other discussion (inspired on the answer of tigerjoker):
    Stay in the album with all the Photos selected.  Select Photos, Batch Change and select Date in the drop down menu.  Input what ever date you want.  Tick the box "Add 1 minute between each photo". Click ok
    Create your book and all the photos should be in the order you selected.
    This worked for me, the original answer from tigerjoker was a bit more complicated:
    Re: iPhoto11 can't rearrange my photos in an album 
    Jun 5, 2011 10:08 AM (in response to Cait9204)
    I had the problem of arranging photos in the album, but when you transfer to a book, it automatically rearranges the photos by date.  As you say, this is a glitch in '11 as it wasn't a problem in earlier version.  I found a solution.  Go to the album and Select All photos.  Select Photos, Batch Change and select Title and Text in the drop down menus.  Type a name in the box, like Birthday Party, then tick the box Append a Number To Each Photo.  Click OK.
    Then, stay in the album with all the Photos selected.  Select Photos, Batch Change and select Date in the drop down menu.  Input what ever date you want.  Untick the box about Add 1 minute between each photo, then tick the box Modify original files.  Click OK.
    Create your book and all the photos should be in the order you selected.

  • Any Tutorial / Sample to create Single PDF from multiple source files using PDF assembler in a watched folder process.

    Any Tutorial / Sample to create Single PDF from multiple source files using PDF assembler in a watched folder process. I have a client application which will prepare number of source files and some meta data information (in .XML) which will be used in header/footer. Is it possible to put a run time generated DDX file in the watch folder and use it in Process. If possible how can I pass the file names in the DDX. Any sample Process will be very helpful.

    If possible, make use of Assembler API in your client application instead of doing this using watched folder. Here are the Assembler samples :  LiveCycle ES2.5 * Programming with LiveCycle ES2.5
    Watched folder can accept zip files (sample : Configuring a watched folder to handle multiple input files and write results to a single folder | Adobe LiveCycle Blog ). You can also use execute script to create the DDX at runtime : LiveCycle ES2 * Application Development Using LiveCycle Workbench ES2
    Thanks
    Wasil

  • I am running Acrobat X Pro on Windows 7 in Parallels. I have tried to install the Acrobat updates, but they won't install. Today I tried to create a pdf from a Word 2013 document and it crapped out. I tried to uninstall Acrobat and got Error 1310. Error w

    I am running Acrobat X Pro on Windows 7 in Parallels. I have tried to install the Acrobat updates, but they won't install. Today I tried to create a pdf from a Word 2013 document and it crapped out. I tried to uninstall Acrobat and got Error 1310. Error writing to file: c:\Config.Msi\feea.rbf. What do I do?

    Hi Beverly ,
    Please refer to the following and see if this helps.
    https://helpx.adobe.com/creative-suite/kb/error-1310-error-writing-file.html
    Regards
    Sukrit Dhingra

  • Build error when trying to creat the project from inactive DC..

    Hello Experts,
    When I am trying to create a project from the inactive DC its giving and error message like build failed.When I switch to webdypro prespective I can see the project created.So please help me out in resolving the issue.
    Thanks,
    Harish.

    Hi Harish,
    Are you able to see the code and the components in the Webdynpro perspective. You can try the different options like Reload, Repair and Refresh.
    See in the log why the build is failing.
    Also check this thread:
    JDI:Import an existing DC fails BUILD; Used component not found: javaLib
    May be it helps.
    Regards.
    Rajat

  • Creating and selecting from a dynamic table

    Hi,
    Iam trying to create a table dynamically and selecting from it in same plsql block, but am getting "table doesnot exist" error. however if i just create a table dynamically and then do a select on it seperately it works..
    below is sample code for the same,
    working
    Line: -----
    DECLARE
    loc VARCHAR2(20):='bglr';
    l_cnt pls_integer;
    BEGIN
    -- create an employee information table
    EXECUTE IMMEDIATE
    'CREATE TABLE ' || 'emp_bglr' ||
    empno NUMBER(4) NOT NULL,
    ename VARCHAR2(10),
    job VARCHAR2(9),
    sal NUMBER(7,2),
    deptno NUMBER(2)
    end;
    select count(*) from emp_bglr ...works and return me 0 rows
    Line: -----
    but when i include select in plsql block ..it throws "Table does not exists" error...(iam running below plsql block after dropping the created table)
    not working
    Line: -----
    DECLARE
    loc VARCHAR2(20):='bglr';
    l_cnt pls_integer;
    BEGIN
    -- create an employee information table
    EXECUTE IMMEDIATE
    'CREATE TABLE ' || 'emp_bglr' ||
    empno NUMBER(4) NOT NULL,
    ename VARCHAR2(10),
    job VARCHAR2(9),
    sal NUMBER(7,2),
    deptno NUMBER(2)
    --COMMIT;
    END;
    Select count(*) into l_cnt from emp_bglr;
    dbms_output.put_line('cnt is '||l_cnt);
    end;
    Line: -----

    Becuase your code is first checked for syntax/object existance during compilation and throws an error saying the table does not exist.
    Try this:
    SQL> ed
    Wrote file afiedt.buf
      1   DECLARE
      2   loc VARCHAR2(20):='bglr';
      3   l_cnt pls_integer;
      4   BEGIN
      5   -- create an employee information table
      6   EXECUTE IMMEDIATE 'CREATE TABLE emp_bglr(
      7   empno NUMBER(4) NOT NULL,
      8   ename VARCHAR2(10),
      9   job VARCHAR2(9),
    10   sal NUMBER(7,2),
    11   deptno NUMBER(2)
    12   )';
    14  Select count(*) into l_cnt from all_objects where object_name = 'EMP_BGLR';
    15  dbms_output.put_line('tab cnt is '||l_cnt);
    16  IF (l_cnt = 1) THEN
    17  l_cnt := 0;
    18  EXECUTE IMMEDIATE 'SELECT count(*) from apps.emp_bglr' into l_cnt;
    19  dbms_output.put_line('data cnt is '||l_cnt);
    20  END IF;
    21* end;
    SQL> /
    tab cnt is 1
    data cnt is 0
    PL/SQL procedure successfully completed.
    SQL> Edited by: AP on Aug 5, 2010 5:51 AM
    Edited by: AP on Aug 5, 2010 5:52 AM

  • Data Corrupted when using CREATE AS SELECT * FROM over DB LINK

    Hi ,
    I wonder if anyone has suffered a simillar issue as this:
    I have a DB Link Between a 10gR1 (Base install not patched) database on Windows 2003, and a 10gR2 (with latest Patch Database ) on Sun Solaris. The 10.1 DB is the SOURCE 10.2 is TARGET
    When using a statement like the following on the Target :
    CREATE TABLE a AS SELECT * FROM TABLE a@SOURCE
    The statement completes, however for some (not all) tables, the data content is seriously corrupted, I noticed this when trying to apply a UKey on the newly created table in TARGET. The data was completely messed up for around 600 out of 450000 rows, I could not easily tell which rows were messed up as it was the columns that build the UKey that were affected :-(
    The same happens if I precreate the table and use INSERT /*+APPEND*/ INTO AS SELECT.... etc
    I realise that using an unpatched 10.1 is not nessasarily advisable, however currently it is difficult for us to patch or upgrade the DB...
    If anyone has seen this before an/or has any ideas what might be the cause , I would appreciate any help I can get.
    Cheers
    JAmes

    The Problem Manifest itsself in that some fileds are created with incorrect Values, specificaly in easy to identify cases NULL where the original values where not NULL.
    These field do not contain special chars like ä or ß , so it does not seem to indicate a charset issue.
    JAmes

  • Selecting from two tables

    I have two tables:
    TABLE: users (user_is is primary key):
    ++++++++++++++++++++++++++++++++++++++
    user_id     | username
    1     | fazle
    2     | newaz
    3     | shaerul
    4     | badsha
    5     | mirmohsin
    6     | mdmohsin
    7     | shawkat
    8     | ahsan
    9     | admin
    TABLE: key_movement_history (history_id is primary key, key_handover_user_id and     key_takeover_user_id links to users.user_id):
    ++++++++++++++++++++++++++++++++++++++++++++++++++
    history_id     | handover_date     | key_handover_user_id |     key_takeover_user_id
    1     | 2006-10-18 16:25:07     | 8               |      2
    2     | 2006-10-18 17:03:09          | 2               |      8
    3     | 2006-10-18 17:04:45     |     8               |     1
    4     | 2006-10-18 17:28:35     |     1               |      8
    5     | 2006-10-18 17:31:59          | 8               |      1
    6     | 2006-10-19 19:04:02          | 1               |     8
    What is want is:
    TABLE 3:
    ++++++++
    handover_date     | key_handover_username | key_takeover_username
    2006-10-18 16:25:07     | ahsan     | newaz
    2006-10-18 17:03:09     | newaz          | ahsan
    2006-10-18 17:04:45     | ahsan          | fazle
    2006-10-18 17:28:35     | fazle          | ahsan
    2006-10-18 17:31:59     | ahsan          | fazle
    2006-10-19 19:04:02     | fazle          | ahsan
    Could anyone please tell me the select statement?
    I tried
    SELECT key_movement_histories.handover_date, users.username, users.username FROM key_movement_histories, users WHERE users.user_id = key_movement_histories.key_handover_user_id and users.user_id = key_movement_histories.key_takeover_user_id;
    but this did not work.
    Thanks in advance.
    Message was edited by:
    user538091

    sql>select * from t1;
        USER_ID  USERNAME
        1  Fazle 
        2  Nawaz 
        3  Sherul
    sql>select * from t2;
        HISTORY_ID  DT  HO_ID  TO_ID
        1  06-oct-06  1  2 
        2  16-oct-06  2  3 
        3  26-oct-06  3  1
    sql>select t2.history_id,t2.dt,
           t11.username ho_user,t12.username to_user
        from t1 t11,t1 t12,t2
        where t11.user_id = t2.ho_id
        and t12.user_id = t2.to_id;
        HISTORY_ID  DT  HO_USE  TO_USE 
        1  06-oct-06  Fazle  Nawaz 
        2  16-oct-06  Nawaz  Sherul 
        3  26-oct-06  Sherul  Fazle 
    jeneesh

  • Single pivot from two different Essbase Cubes

    Hi All,
    I need to show the data from two different cubes into a single Pivot.
    Is that can be achive at different levels like :-
    1. Repository
    2. Answers
    3. Essbsae
    If there is any another way to solve this problem.
    Thanks In Advance
    Brijesh.

    Hi ,Banerjee.
    Asuume that you Cube Structures like below..
    Cube -1 :  Clime No, Cliime Name, Location, Amount1, Amount2.
    Cube -2 :  Clime No, Plant, Material, Location, Amount3, Amount4.
    In your Multiprovider you need to select the Charecteristics "Clime No" , and "Location" ,becasue it is common in both Cubes
    and In Keyfigure : You can select all or only one or only two or one from Cube -1 and other from Cube - 2 it doesn't matter.
    In this case it will disply in single line, but in your case I hope the charecteristics which you are selected in Multiprovider in Identification is wrong, if you don't select common Charecteristics, you won't get the report in single line.
    For reference you can see the following BLOG which will explain exactly your problem and Solution.
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417500)ID0672843250DB01550372956869897428End?blog=/pub/wlg/4478
    Thanks
    Reddy

  • Retriving single field from two tables which are unrelated

    Hi experts..
           i would like to retrieve a field say X from two database tables TAB1 and TAB2 which are unrelated . Can you give me a way to retrive the field X from TAB1 and TAB2 in a single select statement on perticular condition.
    Reward points if aswered..

    Hi,
    If the field is in two tables,you can use for all entries. But anyway two select statemetns are needed.
    If you want single select statement, try using subquery.

  • I am trying to create a pdf from a webpage.

    I'm trying to print a pdf from a website page. The top part of the final pdf is normal but the bottom part of the page is scrunched up and the bottom fourth of the page is blank. This has been a recent occurence.
    Thanks

    Hi rose%20msmith19071310,
    Sure thing! Please follow these steps:
    Log on to https://cloud.acrobat.com/convertpdf using your Adobe ID/email address and password.
    Click Select Files to Convert to PDF.
    Navigate to the scanned document, and select it.
    Click Choose. Your file will be converted, and then saved to your online account at http://cloud.acrobat.com/files.
    Note that you can't scan directly to PDF using Adobe PDF Pack--you need to save the file from your scanner first.
    Please let us know if you have additional questions.
    Best,
    Sara

Maybe you are looking for