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

Similar Messages

  • 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 Multiple Tables but requiring data to match from a 3rd table

    Hello Everyone,
    I'm having alot of trouble with this select
    I have three tables:
    prod_poured, conc_test, and cyl_breakTo put together my report, I need to grab this data:
    cyl_break.pour_no "Pour Number", cyl_break.cyl_id "Cylinder ID", cyl_break.pour_d "Pour Date", conc_test.mix "Mix #", conc_test.amb_t "Ambient Temperature", conc_test.conc_t "Concrete Temperature", conc_test.air "Air %", cyl_break.break_d "Break Date", cyl_break.age "Age (Days)", cyl_break.spec_str "Specified Strength", cyl_break.str "Specimen Strength"and I need it to grab all data in those two tables when one column in the prod_poured table meets a certain condition
    This is what I have so far:
    select cyl_break.pour_no "Pour Number", cyl_break.cyl_id "Cylinder ID", cyl_break.pour_d "Pour Date", conc_test.mix "Mix #", conc_test.amb_t "Ambient Temperature", conc_test.conc_t "Concrete Temperature", conc_test.air "Air %", cyl_break.break_d "Break Date", cyl_break.age "Age (Days)", cyl_break.spec_str "Specified Strength", cyl_break.str "Specimen Strength"
    from conc_test inner join cyl_break on conc_test.pour_no = cyl_break.pour_no, prod_poured
    where conc_test.pour_no = prod_poured.test_id and prod_poured.job_no = '9-12-821';It gives me the right results but wayyy too many of them so obviously I've got something wrong.
    the results it gives are this:
    Pour Number     Cylinder ID     Pour Date     Mix #     Ambient Temperature     Concrete Temperature     Air %     Break Date     Age (Days)     Specified Strength     Specimen Strength
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6The results I need it to give are this:
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49As you can see my query provides the right results, just way too many of them. I only need to have one result per cylinder id.
    I can't seem to wrap my mind around this one and if somebody could put together a proper select based on what I need that would be extremely helpful. If you need any more data to provide help just ask and I'll paste it.
    Thanks,
    dtr
    Edited by: dtr on Apr 26, 2010 11:12 AM

    dtr wrote:
    Hi,
    Here are the create table statements:
    create table conc_test
    (p_date date, job_no varchar, mix varchar, pour_no varchar, amb_t varchar, conc_t varchar, slump varchar, air varchar, density varchar, cyl_cast_time timestamp)
    create table cyl_break
    (job_no varchar, pour_no varchar, cyl_id varchar, pour_d varchar, break_d varchar, age varchar, spec_str varchar, str varchar, mix);
    create table prod_poured
    (prod_id varchar, pour_id varchar, test_id varchar);
    Great!
    Don't forget to post the INSERT statements, and the output from that data (if it is different from what you posted in your first message).
    Basically I need to pull the data I showed above out of conc_test and cyl_break, but only data that has the proper job_number which is retrieved from the prod_poured table. The prod_poured test_id for everything that has the proper prod_poured job_no So an IN-subquery, like Sudhakar and I suggested, should work.
    What was the problem when you tried them? Post the query you ran, even if you just copied and pasted it from this thread: there may have be an editing error.
    prod_poured test_id is the same thing as conc_test pour_no and cyl_break pour_noExactly! But that doesn't answer the question: Is that value unique in all the tables? If not, in which tables can it be duplicated?

  • Display columns from two tables without making join

    Hi,
    I need to perform currency conversion in the report.
    For eg:) Whatever the currency in ar_payment_schedules i want to
    convert it to INR equivalent.
    Following is the query to do this.
    select ps.invoice_currency_code Currency_B,
         decode(ps.invoice_currency_code, 'INR',ps.amount_due_original,
                   round(ps.amount_due_original*
                                  ps.exchange_rate,
                             curr.precision)
         from
              ar_payment_schedules     ps,
              fnd_currencies          curr
         where ps.customer_id          = '111'
         and curr.currency_code      = 'INR'
    When i do this in the Administration tool, the answers modules erroring out saying
    that no joins between ar_payment_schedules and fnd_currencies. But here join is
    not needed becuase fnd_currencies is filtered with INR and will return only
    one row. Without joining two tables how can i get the same results in Answers.
    thanks,
    Prasanna

    If it would return only one row then what is the need for the join (is it just for returning the precision?). Cant you just hard code the precision value instead of getting it from the table? Also you are doing a cartesian join, though the filters would take care of the final output this would result in a bad performance as your data starts scaling out. You need to find a key to join these 2 tables. If you do not have one, then just create a view with the cartesian join alone and then use that in your report.
    Thanks,
    Venkat
    http://oraclebizint.wordpress.com

  • SELECT from two tables

    Hello, I have a problem writing a specific SELECT statement and I hope you'll help me out.
    I have two tables:
    Clients:
    - ID integer (PK)
    - Name_SecondName varchar(20)
    - Gender char
    - Balance integer
    Investments:
    - ID integer (PK)
    - Amount integer
    - Interest Numeric(3,2)
    - Client_ID (FK)
    My job is to display a number of men and a number of women who have at least one investment higher than $1000. I'll skip adding the data to the table, my point is just to find a proper construction for the SQL query. Right now I've got this:
    SELECT COUNT(DISTINCT Client_ID), COUNT(DISTINCT Client_ID)
    FROM Clients JOIN Investments
    ON Clients.ID = Investments.Client_ID
    WHERE Amount > 1000;
    Obviously it twice displays the number of clients with an investment higher than $1000. But how do I specify that the first COUNT counts men (Gender='M') and second - women (Gender = 'F') ?? Can anyone help me?
    Edited by: 934019 on 2012-05-13 12:10

    I'm using Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    Here's the code:
    CREATE TABLE Clients
    Client_ID INTEGER PRIMARY KEY,
    Name_SecondName VARCHAR(20),
    Gender CHAR,
    Balance INTEGER
    CREATE TABLE Investments
    Investment_ID INTEGER PRIMARY KEY,
    Amount INTEGER,
    Interest NUMERIC(3,2),
    Client_ID INTEGER REFERENCES Clients(Client_ID)
    INSERT INTO Clients VALUES (1, 'Brad_Pitt', 'M', 100000);
    INSERT INTO Clients VALUES (2, 'Angelina_Jolie', 'F', 200000);
    INSERT INTO Clients VALUES (3, 'George_Clooney', 'M', 250000);
    INSERT INTO Clients VALUES (4, 'Meryl_Streep', 'F', 150000);
    INSERT INTO Clients VALUES (5, 'Colin_Farrell', 'M', 200000);
    INSERT INTO Clients VALUES (6, 'Scarlett_Johansson', 'F', 400000);
    INSERT INTO Investments VALUES (1, 10000, 4.25, 4);
    INSERT INTO Investments VALUES (2, 20000, 4.65, 3);
    INSERT INTO Investments VALUES (3, 15000, 3.85, 2);
    INSERT INTO Investments VALUES (4, 30000, 4.85, 6);
    INSERT INTO Investments VALUES (5, 25000, 4.5, 3);
    INSERT INTO Investments VALUES (6, 15000, 4.35, 5);
    INSERT INTO Investments VALUES (7, 20000, 4.75, 6);
    INSERT INTO Investments VALUES (8, 10000, 4.15, 1);
    INSERT INTO Investments VALUES (9, 25000, 4.6, 3);
    INSERT INTO Investments VALUES (10, 20000, 4.15, 4);
    And now I make a SELECT statement as follows:
    SELECT COUNT(DISTINCT Client_ID), COUNT(DISTINCT Client_ID)
    FROM Clients NATURAL JOIN Investments
    WHERE Investments. Amount > 15000;
    The result is:
    COUNT (DISTINCT Client_ID) *3*
    COUNT(DISTINCT Client_ID) *3*
    It now displays '3' because there are 3 clients who have at least one investment higher than 15000 (George Clooney, Meryl Streep and Scarlett Johansson).
    So again the question is how to make the first COUNT count only men and the second COUNT - only women? I don't want it to display the clients - just the number of them.

  • Select from 4 tables but include data from 3 even if 4th is null

    Hello -
    I'm quite new to oracle and apex, but enjoying learning - but sometimes I need a gentle nudge to know what I need to learn about.
    I have a select statement that works - selecting specific columns from 3 tables:
    SELECT
    "TERRITORIES"."TER_NAME" "TER_NAME",
    "TERRITORY_TYPES"."TTP_DESCRIPTION" "TTP_DESCRIPTION",
    "COUNTRIES"."CNT_DESCRIPTION" "COUNTRY"
    FROM
    "TERRITORIES", "TERRITORY_TYPES","COUNTRIES"
    WHERE
    "TERRITORIES"."TER_TTP_ID"="TERRITORY_TYPES"."TTP_ID"
    and
    "COUNTRIES"."CNT_TER_ID"="TERRITORIES"."TER_ID"
    I want to add in a 4th table for, you guessed it, States.
    However, many of the countries do not yet have states in the states table (and may never have any). Therefore, they do not appear in the results. I want them included in the query, so that I'll have the opportunity to add in the data via Apex.
    Is there a phrase I can insert in the 1st query so that I'll get data for Territory Type, Territory and Country, even if the State table is null?
    Or, do I need to insert records into the state table, such as: insert into states (state_ID, STATE_CNT_ID) values (state_seq.nextval,2). If so, do I just do that over and over, replacing the value? Or is this where I need to learn about bind variables? Or some other command?
    Thank you-
    Marion in NY
    Edited by: mtpaper on Oct 24, 2009 12:54 PM
    I FIGURED IT OUT! I DID IT! How do I mark myself as helpful???
    insert INTO states
    (state_ID, STATE_CNT_ID)
    SELECT state_seq.nextval, cnt_id
    FROM countries
    WHERE not exists (select * from states where states.state_cnt_id = countries.cnt_id)
    Edited by: mtpaper on Oct 24, 2009 1:10 PM

    You certainly could insert data into the STATES table, but I generally wouldn't advise inserting rows into a STATES table for states that don't actually exist. It would seem to make far more sense to just do an outer join when you include the STATES table in your query
    SELECT "TERRITORIES"."TER_NAME" "TER_NAME",
           "TERRITORY_TYPES"."TTP_DESCRIPTION" "TTP_DESCRIPTION",
           "COUNTRIES"."CNT_DESCRIPTION" "COUNTRY",
           s.state_name
      FROM TERRITORIES t ,
           TERRITORY_TYPES tt,
           COUNTRIES c,
           states s
    WHERE "TERRITORIES"."TER_TTP_ID"="TERRITORY_TYPES"."TTP_ID"
       and "COUNTRIES"."CNT_TER_ID"="TERRITORIES"."TER_ID"
       and c.cnt_id = s.state_cnt_id(+)The {noformat}(+){noformat} operator indicates that you want to do an outer join. So if there is no row in the STATES table that matches the join condition, a NULL is returned.
    From a purely stylistic standpoint, I would generally suggest using aliases (i.e. the T, TT, C, and S in the FROM clause) rather than having to constantly write out all the table names. And I wouldn't suggest putting double-quotes around everything-- that forces all your identifiers to be upper case and case sensitive.
    Justin

  • 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

  • Distinct rows from two tables linked by a third one

    Hi,
    I need to write an SQL sentence to bring a group of DISTINCT rows, each row in a form of: A.X, A.Y, C.IDBOLETA. Tables A and C are linked through the table C, as follow:
    Table A: INDUSTRIAGEO
    NIT VARCHAR2(20) NOT NULL,
    CORRELAIGEO NUMERIC(2) NOT NULL,
    NOMBREAGENCIA VARCHAR2(255) NOT NULL,
    DIRECCION VARCHAR2(255),
    X NUMERIC(12,8) NOT NULL,
    Y NUMERIC(12,8) NOT NULL,
    CONSTRAINT PKGEOINDUST PRIMARY KEY(NIT, CORRELAIGEO),
    CONSTRAINT FKGEOINDUST FOREIGN KEY(NIT) REFERENCES INDUSTRIA(NIT)
    Table B: ANALISIS
    IDANALISIS NUMERIC(12) NOT NULL,
    NIT VARCHAR2(20) NOT NULL,
    CORRELAIGEO NUMERIC(2) NOT NULL,
    FECHA DATE NOT NULL,
    IDINSPECTOR NUMERIC(4) NOT NULL,
    CONSTRAINT PKANALISIS PRIMARY KEY(IDANALISIS),
    CONSTRAINT FKANALGEOI FOREIGN KEY(NIT, CORRELAIGEO) REFERENCES INDUSTRIAGEO(NIT, CORRELAIGEO),
    CONSTRAINT FKANALINSP FOREIGN KEY(IDINSPECTOR) REFERENCES INSPECTOR(IDINSPECTOR)
    Table C: ANALISISBOLETA
    IDANALISIS NUMERIC(12) NOT NULL,
    CORRELAANALISIS NUMERIC(2) NOT NULL,
    IDBOLETA NUMERIC(12) NOT NULL,
    IDCATEGORIAINDUSTRIA NUMERIC(3) NOT NULL,
    CONSTRAINT PKANALBOLE PRIMARY KEY (IDANALISIS, CORRELAANALISIS),
    CONSTRAINT UKANALBOLE UNIQUE (IDBOLETA),
    CONSTRAINT FKANALBOLE FOREIGN KEY(IDANALISIS) REFERENCES COPS.ANALISIS(IDANALISIS),
    CONSTRAINT FKANALCATI FOREIGN KEY(IDCATEGORIAINDUSTRIA) REFERENCES COPS.CATEGORIAINDUSTRIA(IDCATEGORIAINDUSTRIA)
    Thanks for your help!!!
    Mario

    Perhaps
    select distinct a.x,a.y,c.idboleta
      from industriaego a,
           cops.analisis b,
           analisisboleta c
    where a.nit = b.nit
       and a.correlaigeo = b.correlaigeo
       and b.idanalisis = c.idanalisisRegards
    Etbin
    Edited by: Etbin on 4.5.2010 21:42
    the copy/paste elf did it again: b.correlaigeo instead of b.a.correlaigeo (as in the OP's comment below)

  • Retrieve data from two tables and store it in one itab

    Hi All,
    i have an internal table of structure which has fields ar_object and objecttext.
    I want to retrieve all the ar_object from table toaom for object type BUS2012 and then the corresponding objecttext from toasp where toaom-ar_object = toasp-ar_object and then store both this values in my internal table.
    what is the best method to do it ?  Please let me know if you want to know how i am doing it right now
    thanks,
    Golu

    Hi,
    You can get many ways 
    1. using  For all entries in 
    2. using Inner join
    3. you can get 2 tables data into 2 different internal tables  and   loop first internal table and read second internal using key fields append it another internal table or modify second internaltable.
    In above ways 1st and 2nd are performance issues.   the best way is
    get TOAOM table data into itab1 and get TOASP table data into itab2 you can append data into another itab3 or modify itab2
    regards,
    Ganesh

  • Selection from different tables

    Hello Everyone,
    I have a situation where I have 15 fields in the selection screen.
    The selection is dependent on three or more tables.
    First I have selected from two tables but if the user enters values in the selection screen then how to make the selection.
    Tables dont have common fields between them. LIKP, LIPS, VTTK, VBUK and VEKP are the tables.
    Can you guys guide me.
    Thank you.

    Hi Vinod,
    First I have selected from two tables but if the user enters values in the selection screen then how to make the selection.
    Your query is not so clear. When are you fetching the data from two table whether before selection screen input (Initialization event) or after selection screen?
    Can you please elaborate your query and better if you post your Selection Screen screen-shot.
    Regards,
    VIjay

  • Urgent. . .About select * from multiple tables

    When I am doing the 'Select * from tables' in JSP,
    sql = dbconn.prepareStatement("SELECT * FROM protein WHERE protein_id ='"+p_i+"'");
    It works, because I only select one table.
    Then, I change to select from two tables,
    sql = dbconn.prepareStatement("SELECT * FROM protein, fuses WHERE protein_id ='"+p_i+"'");
    It also works properly?
    However, When I do like:
    sql = dbconn.prepareStatement("SELECT * FROM protein, protein_taxa WHERE protein_id ='"+p_i+"'");
    It doesn?t work.
    So, I think it might be the problem that there is a common column 'protein_id' in both tables, although protein_taxa.protein_id is a foreign key of protein.protein_id. Therefore, I can select two table protein, fuses which have different columns, but no way to select the table they have same name column.
    However, it?s essential for me to select all the data from the database. Any way I could achieve it? Thanks a lot!!

    SELECT *
    FROM protein, protein_taxa
    WHERE protein.protein_id = 'a_protein_id'
    and protein.protein_id = protein_taxa.protein_id It would also be good to indicate which fields you want on the select clause. This will liberate the server to return two fields with the same name.
    SELECT protein.protein_id, protein.name, protein_taxa.taxa /* ??? */
    FROM protein, protein_taxa
    WHERE protein.protein_id = 'a_protein_id'
    and protein.protein_id = protein_taxa.protein_id

  • Selecting columns from two table is slow but same

    I am selecting 27 columns from two tables
    which running for more than 30 minutes. but
    if I select count(*) with the same query
    except the columns it is coming in seconds.
    Where is the error?

    If you post
    1) The table definitions for the underlying tables
    2) The indexes that are on the tables
    3) The two SQL statements you're running
    4) The explain plan for both statements
    we can probably be of some assistance.
    My guess is that the count(*) is able to return much more quickly because the optimizer is able to use a significantly faster query plan that is based on an index which the longer-running query cannot utilize. Without the information I've requested, though, it's hard to do more than speculate.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Need of SQL query in selecting distinct values from two tables

    hi,
    I need a query for selecting distinct values from two tables with one condition.
    for eg:
    there are two tables a & b.
    in table a there are values like age,sex,name,empno and in table b valuses are such as age,salary,DOJ,empno.
    here what i need is with the help of empno as unique field,i need to select distinct values from two tables (ie) except age.
    can anybody please help me.
    Thanks in advance,
    Ratheesh

    Not sure what you mean either, but perhaps this will start a dialog:
    SELECT DISTINCT a.empno,
                    a.name,
                    a.sex,
                    b.salary,
                    b.doj
    FROM    a,
            b
    WHERE   a.empno = b.empno;Greg

  • Select data from two tables...!

    HI Experts...!
    i m a beginner user and i want to select data from two tables proj and prps.....using joins.....and internal tables i have written a code...
    SELECT prps~pspnr
           prps~objnr
           prps~psphi
           proj~ernam
           proj~erdat
           proj~pspnr
    INTO  table itab   -
    itab is internal table
    FROM prps inner join proj
    WHERE pspnr in p_no and prpspsphi = projpspnr.
    but there is error in from clause ..please help me....
    Advance thanx....

    Hi,
    check the sample code bellow above two reply will solve out your problem but one more extra line in your code pointed out bellow.
    TABLES: prps, proj.
    TYPES:  BEGIN OF ty_test,
            pspnr LIKE prps-pspnr,
            objnr LIKE prps-objnr,
            psphi LIKE prps-psphi,
            ernam LIKE proj-ernam,
            erdat LIKE proj-erdat,
            END OF ty_test.
    DATA: itab TYPE STANDARD TABLE OF ty_test WITH HEADER LINE.
    SELECT-OPTIONS: p_no FOR prps-pspnr.
    SELECT  prps~pspnr
            prps~objnr
            prps~psphi
            proj~ernam
            proj~erdat
    *        proj~pspnr " No need for this you have selected this in
    *     the first line because it is commone so you only need to select from any one
            INTO TABLE itab
    FROM prps INNER JOIN proj ON ( prps~pspnr = proj~pspnr  )
    WHERE prps~pspnr IN p_no.
    Best Regards,
    Faisal
    Edited by: Rob Burbank on Dec 24, 2009 12:24 PM

Maybe you are looking for

  • HT1918 How do I take credit card off my iTunes account

    How do I erase a credit card off my account

  • How can I fix safari that is crashing continuosly ?

    Process:               Safari [1476] Path:                  /Applications/Safari.app/Contents/MacOS/Safari Identifier:            com.apple.Safari Version:               8.0.2 (10600.2.5) Build Info:            WebBrowser-7600002005000000~1 Code Type

  • Can't open my songs in iTunes

    Hi I installed iTunes match and have uploaded my songs. Now a lot of songs appear more brightly grey (not black) with a cloud, so i can't open, steam, listen, them. Can someone help me? Thank you! Greetings from switzerland and sorry for my bad engli

  • Loss of sound after iOS 7 download on iPad 2

    Help!  I've noticed that since the. Download of iOS 7, I have begun to lose sound in most games and apps as well as keyboard, etc..  Music does produce sound.  Certain games that produced sound immediately following the download, i.e. Plants vs Zombi

  • Flash crash and color changes

    in CS3 I have jpegs and gifs along all with a background that is the same color across photoshop and flash, and it looks fine in the development environment, but when I make a swf file the colors shift and it no longer looks correct. I also get artif