Combinig two tables without a JOINER

Hi,
I got a little problem. I want to combine two tables. But I don't need a joiner, cause that would give me wrong combined values.
I have a table working_hours which has the actual working hours of employees. And a table times_absent which has the absent time of the employees.
Both tables have the date and actual hours of work and absent besides other tings in it.
I simple want to combine these two tables to one big table.
Example:
Table working_hours :
Name --- Date --- Hours -- ....
Mr.A --- 2.5.2011 --- 8 --- ...
Mr.B --- 2.5.2011 --- 6 --- ...
Mr.C --- 2.5.2011 --- 7 --- ...
Table times_absent:
Name --- Date --- Days --- ....
Mr.A --- 3.5.2011 --- 1 --- ...
Mr.B --- 3.5.2011 --- 2 --- ...
Mr.B --- 4.5.2011 --- 2 --- ...
New Table:
Name --- Date --- Working_Hours --- Absent_Days ---
Mr.A --- 2.5.2011 --- 8 ---- null - or some sort of dummy value XXX
Mr.A --- 3.5.2011 --- null --- 1 ---
Mr.B --- 2.5.2011 --- 6 --- null ---
Mr.B --- 3.5.2011 --- null --- 2 ---
Mr.B --- 4.5.2011 --- null --- 2 ---
and so one.
Is there a possibility in the OWB to perform such task?
thx

As MccM says you need to make the columns in your IN groups the same i.e. the same structure as your new table.
Connect WORKING HOURS to IN GROUP 1 and ABSENT to IN GROUP 2 for the columns that exist.
Create a numeric CONSTANT with a default value of NULL and connect that to ABSENT_DAYS in IN GROUP 1 and WORKING_HOURS in IN GROUP 2.
You don't need to change the structure of your tables.

Similar Messages

  • 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

  • Query for Linking Two Tables without Reference

    Hi Folks,
    Good Day!
    I have this dilemma on how to link two tables without a reference. In the Business Partner Master Data, there is a field for the Territory which is from the table OTER. This OTER focuses on its description. Once you have added the particular Territory for that Business Partner, it is being stored in the Territory field of the BP right? Our client wants to have an automated way of searching for the Business Partner's Profit Center in creating a Sales Order wherein it is the same as the Business Partner's Territory. The Profit Center is from the table OPRC.
    When I create a Sales Order, after I have entered the Business Partner/Customer Code, the Profit Center should have the value of the Profit Center Code wherein it is the Business Partner's Territory. My query will go like this:
    Enter the BP/Customer Code automatically the Profit Center code where Profit Name = BP's Territory.
    OTER and OCRD don't have connections. How can it be?
    I'm thinking of retrieving the Territory first before the Profit Center but can you suggest of any other way?
    Thank you much!
    Regards,
    Fringe

    Hi Fringe,
    Okay, I already understood your case here. I presume your configuration as follows:
    OTER (Territory)
    territryID - descript
    1 - Philippine
    2 - Indonesia
    3 - Germany
    OPRC (Cost Centre)
    PrcCode - PrcName
    25 - Philippine
    33 - Indonesia
    47 - Germany
    Was above illustration correct? Then, you could use this formatted search in Cost Centre / Dimension field in Sales Order rows
    SELECT PrcCode FROM OPRC WHERE PrcName=(
    SELECT TOP 1 descript FROM OTER T0
    INNER JOIN OCRD T1 ON T0.territryID=T1.Territory
    WHERE T1.CardCode=$[OCRD.CardCode.0])
    However, I suggest you use a little bit different approach here. Since you can't define Territory Code / Territory ID (you could only type the Territory name, Philippine etc.), why don't you standardize Territory name with Cost Centre code? Let say, you define Philippine as PHI, Indonesia as INA, Germany as DEU and so on. Therefore, user can read the Cost Centre or more precisely Distribution Rules in Sales Order form in more familiar way.
    OTER (Territory)
    territryID - descript
    1 - PHI
    2 - INA
    3 - DEU
    OPRC (Cost Centre)
    PrcCode - PrcName
    PHI - Philippine
    INA - Indonesia
    DEU - Germany
    When FMS worked in Sales Order document, your user will read PHI instead of 25, should be more familiar to them. With that being said, you could use simpler FMS
    SELECT descript FROM OTER T0
    INNER JOIN OCRD T1 ON T0.territryID=T1.Territory
    WHERE T1.CardCode=$[OCRD.CardCode.0]
    You only need to maintain consistency between Territory Name and Cost Centre code. Just my two cents. Hope this help.
    Best Regards,
    Hendry Wijaya

  • Combining two tables without any distinct columns between them

    Folks,

    Hi sidy2j,
    According to your description, we need to verify your table structures, and the actual results which you want to get from your tables. Please post more information for analysis.
    Assume, if you want to a one to one record mapping between  two tables without any common column between them for joining, you can refer to the following scripts to implement your requirement. For more information, see:
    http://sqlhints.com/2013/09/07/joining-two-tables-without-any-common-column-between-them-sql-server/
    If you want to match every row in the first table with every row in the second table, you can refer to the following detail.
    http://stackoverflow.com/questions/1198124/combine-two-tables-that-have-no-common-fields
    Hope it can help you.
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Need help to join two tables using three joins, one of which is a (between) date range.

    I am trying to develop a query in MS Access 2010 to join two tables using three joins, one of which is a (between) date range. The tables are contained in Access. The reason
    the tables are contained in access because they are imported from different ODBC warehouses and the data is formatted for uniformity. I believe this cannot be developed using MS Visual Query Designer. I think writing a query in SQL would be suiting this project.
    ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
    [ABCTABLE]
    ABCORDER
    ABCPART
    ABCSERIAL
    ABCDATE
    [ZYXTABLE]
    XYZORDER
    XYZPART
    XYZSERIAL
    XYZDATE1
    XYZDATE2

    Thank you for the looking at the post. The actual table names are rather ambiguous. I renamed them so it would make more sense. I will explain more and give the actual names. What I do not have is the actual data in the table. That is something I don't have
    on this computer. There are no "Null" fields in either of the tables. 
    This table has many orders (MSORDER) that need to match one order (GLORDER) in GLORDR. This is based on MSPART joined to GLPART, MSSERIAL joined to GLSERIAL, and MSOPNDATE joined if it falls between GLSTARTDATE and GLENDDATE.
    [MSORDR]
    MSORDER
    MSPART
    MSSERIAL
    MSOPNDATE
    11111111
    4444444
    55555
    2/4/2015
    22222222
    6666666
    11111
    1/6/2015
    33333333
    6666666
    11111
    3/5/2015
    This table has one order for every part number and every serial number.
    [GLORDR]
    GLORDER
    GLPART
    GLSERIAL
    GLSTARTDATE
    GLENDDATE
    ABC11111
    444444
    55555
    1/2/2015
    4/4/2015
    ABC22222
    666666
    11111
    1/5/2015
    4/10/2015
    AAA11111
    555555
    22222
    3/2/2015
    4/10/2015
    Post Query table
    GLORDER
    MSORDER
    GLSTARTDATE
    GLENDDATE
    MSOPNDATE
    ABC11111
    11111111
    1/2/2015
    4/4/2015
    2/4/2015
    ABC22222
    22222222
    1/5/2015
    4/10/2015
    1/6/2015
    ABC22222
    33333333
    1/5/2015
    4/10/2015
    3/5/2015
    This is the SQL minus the between date join.
    SELECT GLORDR.GLORDER, MSORDR.MSORDER, GLORDR.GLSTARTDATE, GLORDR.GLENDDATE, MSORDR.MSOPNDATE
    FROM GLORDR INNER JOIN MSORDR ON (GLORDR.GLSERIAL = MSORDR.MSSERIAL) AND (GLORDR.GLPART = MSORDR.MSPART);

  • How to specify more than Two Tables in NATURAL JOIN

    Hi,
    I am using Oracle9i R-2. I want help in writing a Query using Two Tables in SQL*PLUS. I am using ANSI/ISO Standrard for table-joins:
    select col1, col2, descr
    from tab1 natural join tab2
    There are two columns col1 & col2 is common between thse two tables. So, it will join them and query execute well.
    How can i use 3rd table tab3 in the same way in Natural Join...? If column col1 & col2 is available in tab3 also.
    I tried this way, but it gives me error:
    select col1, col2
    from tab1 natural join tab2 natural join tab3
    Is it possible to specify more than two tables in Natural Join Clause.
    Please check that out & help please. Thanks.
    Regards,
    Kamesh Rastogi

    I do not get an error when I try the same thing on the same version, as demonstrated below. Can you post your table structure and a copy and paste of a run of your actual query with the error that you are receiving?
    scott@ORA92> select banner from v$version
      2  /
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    PL/SQL Release 9.2.0.1.0 - Production
    CORE     9.2.0.1.0     Production
    TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
    NLSRTL Version 9.2.0.1.0 - Production
    scott@ORA92> select * from tab1
      2  /
          COL1       COL2 COL3
             1          1 A
            10         10 B
    scott@ORA92> select * from tab2
      2  /
          COL1       COL2 COL4
             1          1 C
            20         20 D
    scott@ORA92> select * from tab3
      2  /
          COL1       COL2 COL5
             1          1 E
            30         30 F
    scott@ORA92> select col1, col2, col3, col4, col5
      2  from tab1 natural join tab2 natural join tab3
      3  /
          COL1       COL2 COL3 COL4 COL5
             1          1 A    C    E
    scott@ORA92>

  • Data fetch from two table without refresh

    hi Friends,
    I have a problem i want to extract data from two table without refresh into text field when i'll enter any value in a text field then corressponding value should come in to corressponding textfield.
    eg. there two table A and B.
    Table A has Colunm
    s_id Number;
    c_id Varchar2(30);
    sec varchar2(4);
    Second Table B Colunm Name
    s_id Number;
    f_name varchar(30);
    l_name varchar(20);
    when i enter s_id 101 in a text field then the c_id ,sec,first_name and last_name should come in to corressponding text fields without refresh.
    How Can I do this.
    Thanks
    Manoj

    Hi Manoj,
    You have to make an Ajax call to display data without refreshing the page. Search this forum for Ajax and you can find lots of related posts. This link might help too. http://www.dba-oracle.com/t_html_db_apex_ajax_application_express.htm
    Thanks,
    Manish.

  • How to join two tables without constraints??

    I want get the tables to be joined without constraints!!
    table1 :
    100     get
    101     wet
    102     set
    and
    table 2 :
    10     xxx
    11     yyy
    12 zzz
    I got the output like this,
    output :
    ID NAME ID NAME
    101     wet     10     xxx
    101     wet     12     zzz
    101     wet     11     yyy
    100     get     10     xxx
    102     set     11     yyy
    102     set     10     xxx
    100     get     11     yyy
    100     get     12     zzz
    102     set     12     zzz
    but i want everything to be written once.
    Help me out with this!!???

    Tanx fr the response!
    Nah, but me used toad to run it. And my query is
    QUERY 1 :
    SELECT * FROM PARTES P,CUSTES C
    WHERE (P.ID,P.NAME,C.ID,C.NAME) IN (SELECT P1.ID,P1.NAME,C1.ID,C1.NAME
    FROM PARTES P1,CUSTES C1)
    QUERY 2 :
    select id as pid, name as name from partes
    union
    select id as pid,name as name from custes;
    OUTPUT FOR QUERY2 IS,
    PID NAME
    10     xxx
    11     yyy
    12     zzz
    100     get
    101     wet
    102     set
    In the 2nd query am getting the joined records of both the tables. But my need is both the tables record to be displayed like this
    ID NAME ID_1 NAME_1
    10     xxx 100     get
    11     yyy 101     wet
    12     zzz 102     set
    What i am trying is,i want to join the all the columns parallely in my output!!
    Is there any source mike?

  • JOIN question... Join two tables without omiting rows

    I ran into a problem that should have an easy solution (I hope), but I'm having a hard time coming up with a solution.
    Basically, I have two tables, one with actual amounts and one with the budget. I am to write a sql select statement that joins these tables together and includes all of their rows. I've been able to join the tables together using JOIN, LEFT JOIN, and RIGHT JOIN, but it always omits rows that I need.
    Below, I have examples of my tables (AMOUNT_TABLE and BUDGET_TABLE). For simplicity sake, I've built the examples to show the same values in the first four columns, with the 5th and 6th columns (SUB_ACCOUNT, AMOUNT, BUDGET) as the only values that are different. My actual tables aren't quite as simple, but I didn't think it was relavent for this question.
    AMOUNT_TABLE
    FISCAL_YEAR
    PERIOD
    ACCT_UNIT
    ACCOUNT
    SUB_ACCOUNT
    AMOUNT
    2013
    1
    11111
    555555
    0000
    100
    2013
    1
    11111
    555555
    1000
    100
    2013
    1
    11111
    555555
    2000
    100
    2013
    1
    11111
    555555
    3000
    100
    2013
    1
    11111
    555555
    4000
    100
    BUDGET_TABLE
    FISCAL_YEAR
    PERIOD
    ACCT_UNIT
    ACCOUNT
    SUB_ACCOUNT
    BUDGET
    2013
    1
    11111
    555555
    3000
    200
    2013
    1
    11111
    555555
    4000
    200
    2013
    1
    11111
    555555
    5000
    200
    2013
    1
    11111
    555555
    6000
    200
    Here is the output I'm hoping for. Notice that SUB_ACCOUNTs 0000, 1000, and 2000 show amounts with no budget since there isn't a matching row in the BUDGET_TABLE. And likewise, for SUB_ACCOUNTs 5000 and 6000, they show budgets with no amounts since there isn't a matching row in the AMOUNT_TABLE.
    (output)
    FISCAL_YEAR
    PERIOD
    ACCT_UNIT
    ACCOUNT
    SUB_ACCOUNT
    AMOUNT
    BUDGET
    2013
    1
    11111
    555555
    0000
    100
    0
    2013
    1
    11111
    555555
    1000
    100
    0
    2013
    1
    11111
    555555
    2000
    100
    0
    2013
    1
    11111
    555555
    3000
    100
    200
    2013
    1
    11111
    555555
    4000
    100
    200
    2013
    1
    11111
    555555
    5000
    0
    200
    2013
    1
    11111
    555555
    6000
    0
    200
    Hopefully, my question is clear. Any help on this would be greatly appreciated. Thanks in advance.

    Use ANSI join syntax - FULL OUTER JOIN:
    with amount_table as (
                          select 2013 fiscal_year,1 period,11111 acct_unit,555555 account,0000 sub_account,100 amount from dual union all
                          select 2013,1,11111,555555,1000,100 from dual union all
                          select 2013,1,11111,555555,2000,100 from dual union all
                          select 2013,1,11111,555555,3000,100 from dual union all
                          select 2013,1,11111,555555,4000,100 from dual
         budget_table as (
                          select 2013 fiscal_year,1 period,11111 acct_unit,555555 account,3000 sub_account,200 budget from dual union all
                          select 2013,1,11111,555555,4000,200 from dual union all
                          select 2013,1,11111,555555,5000,200 from dual union all
                          select 2013,1,11111,555555,6000,200 from dual
    select  nvl(a.fiscal_year,b.fiscal_year) fiscal_year,
            nvl(a.period,b.period) period,
            nvl(a.acct_unit,b.acct_unit) acct_unit,
            nvl(a.account,b.account) account,
            nvl(a.sub_account,b.sub_account) sub_account,
            nvl(a.amount,0) amount,
            nvl(b.budget,0) budget
      from      amount_table a
            full join
                budget_table b
              on (
                      a.fiscal_year = b.fiscal_year
                  and
                      a.period = b.period
                  and
                      a.acct_unit = b.acct_unit
                  and
                      a.account = b.account
                  and
                      a.sub_account = b.sub_account
    FISCAL_YEAR     PERIOD  ACCT_UNIT    ACCOUNT SUB_ACCOUNT     AMOUNT     BUDGET
           2013          1      11111     555555           0        100          0
           2013          1      11111     555555        1000        100          0
           2013          1      11111     555555        2000        100          0
           2013          1      11111     555555        3000        100        200
           2013          1      11111     555555        4000        100        200
           2013          1      11111     555555        6000          0        200
           2013          1      11111     555555        5000          0        200
    7 rows selected.
    SQL>
    SY.

  • Join two tables without index scan

    Hi All,
    I have two tables (ProgramMaster, ProgramDetails). ProgramMaster have very less number of records and Programdetails have large number of records
    My Query is
    Please vote if you find this posting was helpful or Mark it as answered.

    Saravanan,
    As you may know, usage of functions over the columns will force the compiler to go for a SCAN and not a SEEK. How about rewriting the query (without using functions) to make way for better usage of the index.
    One option is to make use of a calendar table that would prove to be effective for date operations like this one..
    For more info on calendar table:
    http://www.allaboutmssql.com/2014/01/sql-server-calender-details.html
    http://social.technet.microsoft.com/wiki/contents/articles/22776.t-sql-calendar-table.aspx
    http://blog.jontav.com/post/9380766884/calendar-tables-are-incredibly-useful-in-sql
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • How to use common object from two tables with out join.

    HI,
    I have two tables called A & B In A table i have the following objects
    1.weekend
    2.S1(measure)
    3.S2(measure)
    4.S3(measure)
    5.S4(measure)
    And In B table i have followning columns
    1.week end
    2.p1(measure)
    3.p2(measure)
    4.p3(measure)
    5.p4(measure)
    Now in universe i created all the measure objects i.e.s1,s2,s3,s4,p1,p2,p3,p4 A.weekend,B.weekend.
    instead of using week end two times i wnt to use only once because this is common in both table.
    if i use join between these tables i am getting values fine
    But With out join is there any thing to do in universe level to create common objects to use from both the tables..I tried using aggregate awareness but while reporting it is taking as two SQL.which is not synchronized.
    Please help me on this ...

    hi,
    Although  Weekend column is present in both tables, by creating a single Object in Universe, Universe can identify relationship with only table referenced in Object Creation.
    So, there will be no identification of relationship with other table measures.
    Obviously, you need to create 2 Weekend objects in Universe (in two classes).
    Case 1: You need not join these two tables in Universe. When you create 2 Queries in WEBI, automatcially Weekend objects are synchronized (if both are of same datatype)
    Case 2: If you join these two tables in Universe, Obviously,
    your SQL may contain Weekend from Table1, measures from Table 2
    or
    your SQL may contain Weekend from Table2, measures from Table 1
    Finally, You need to create 2 objects in Universe. But your query may contain a single Object based on Case 2.
    Regards,
    Vamsee

  • Unable to retrive data from two tables using multiple joins

    Hi,
    Table:   EMP mgr 
    eid              name
    eid mgrid
    1
    A 1
    null
    2
    B 2
    3
    3
    C 3
    3
    i need to get result as:
    eid ename mgrname
    thanks
    AVS

    Sai,
    It would be very helpful if you could mention your table structures a bit more clearly. Would allow for effective replies from fellow users as well. :) 
    However, assuming that your structure would be as follows presenting the query as below:
    DECLARE @Emp TABLE(Eid Int, ename Varchar(50))
    DECLARE @Emp_Mgr TABLE(Eid int, mgrid int null )
    INSERT INTO @Emp select 1,'Ram'
    INSERT INTO @Emp select 2,'Shyam'
    INSERT INTO @Emp_Mgr select 1,NULL
    INSERT INTO @Emp_Mgr select 2,1
    SELECT * FROM @Emp
    SELECT * FROM @Emp_Mgr
    Query to print results as EID, ENAME, MGRNAME
    SELECT em.eid,e1.ename as ENAME,e2.ename as MGRNAME
    FROM @Emp_Mgr em
    JOIN @Emp e1 ON em.eid=e1.eid
    JOIN @Emp e2 ON em.mgrid=e2.eid
    However, as you see this approach of maintaining two tables for preserving the employee-manager data is redundant and makes the queries unnecessarily complex. So, you could opt for the widely used single table format as mentioned by Praveen as well. Check
    if this helps you..
    Recommended Structure
    *Avoidance of redundant storage of data
    *Lesser Joins in queries
    DECLARE @Emp TABLE(Eid Int , Ename Varchar(50) , mgrid int null )
    INSERT INTO @Emp(Eid , ename , mgrid) values(1 , 'Ram' , null) , (2 , 'Shyam' , 1)
    SELECT * FROM @Emp
    Query to print results as EID, ENAME, MGRNAME
    SELECT e.Eid , e.Ename , m.Ename as MgrName
    FROM @Emp e
    JOIN @Emp m On a.mgrid = b.eid
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • Combine two tables without common field

    Hi Experts,
    I have two database tables, DBSTATORA(stores inform about all the tables involved in infoproviders), and RSDODSO ( stores information about ODS Objects. I have to list the ods objects and its associated tables as the output, but there is no common field in these two tables how will i combine these two tables, can anyone please suggest me. Any help will be fine.
    thanks,
    Prabhu.

    Hi Everyone,
    I know the ods tables names are stored like /bix/a<ods_name>00 and /bix/a<ods_name>40 and for change log it is /bic/b*. But my requirement is I have to display the size of the tables belonging to a particular ods object. So for all the tables the size is stored in DBSTATTORA which gives information about
    DBSTATTORA
    fields of this tables are:
    TNAME --> Table Name
    ANDAT --> Analyzing Date
    AMETH --> Analysis method for collecting Statistics
    NROWS --> No of rows in a table
    OCCBL --> Used blk(size) of table in KB
    EMPBL --> Empty blk(size) of table in KB
    AFREE --> Avg Freespace in a used db block
    INDBS --> Used Blk(size) of an index kb
    This is a table which stores the statistics information.
    It displays all the tables of infocubes and ods objects, but does tell that this table belongs to this infoprovider.
    I have to display data from this table as well as the infoprovider to which it belongs. So there is no proper information of database tables where the infocube and its associated tables like the facttable, dimtables are stored together. Same for the ods objects also.
    There are for ods object RSDODSOTABL which give information about ods object and the table name is stored differently <ods_name>_0000. How do i map this table with the DBSTATTORA table, the tablenames doesn't match. Same problem with RSTSODS table which give informaiton about change log table.
    And also for infocubes, there is RSDCUBE which gives information about infocubes but not the associated tables. So does anyone know where all these information is stored in some database tables. It would be of great help.
    Thanks a lot.
    Prab

  • Issues while joining two tables as the joining column has duplicate values - Please help!

    Hi,
    I have a table A -which has few columns including a Amount column - I am joining this table A to Table B. The joining column in B has duplicates.  So, the number of records are getting more after the joining. As per the requirment when I create a table
    after joining the tables and count the salary clumn, there is a difference in the counting. How can I solve this? Can you please help me?
    Here is the DDL and sample values
    create table #student (sid int, name varchar(10),salary int)
    create table [#address] (sid int, city varchar(10),grade char(1),lineneumber int)
    insert into #student values (1,'sachin',8000)
    insert into #student values (2,'Dhoni',2000)
    insert into #student values (3,'Ganguly',7000)
    insert into #student values (4,'Kohli',1000)
    insert into [#address] values(1,'mumbai','A',1)
    insert into [#address] values(1,'mumbai','B',2)
    insert into [#address] values(1,'mumbai','C',3)
    insert into [#address] values(1,'mumbai','D',4)
    insert into [#address] values(2,'JARKHAND','D',3)
    insert into [#address] values(2,'JARKHAND','D',4)
    SELECT S.SID,NAME,salary,CITY ,grade,linenumber
    into #FINAL
    FROM #STUDENT S
    LEFT JOIN #ADDRESS A
    ON S.SID=A.SID
    SELECT SUM(salary) FROM #FINAL
    --44000
    Final result should be 18000 , but it is coming as 44000. can you please help me to get the correct result - what do i do in the joining?
    In my real project, i have 5 tables joining, each table have more than 30 columns and few joining tables joining column have duplicates. I have simplified the issue so that i can ask the question clearly. So,while answering, please consider that also in mind.
    thanks in advance for your help!

    SELECT S.SID,NAME,salary,CITY 
    into #FINAL
    FROM #STUDENT S
    LEFT JOIN (SELECT DISTINCT sid,city
    FROM #Address) A
    ON S.SID=A.SIDthis will do a join on student table and city table with unique sid and city name so adddress selection will be sid city1 mumbai2 jarkand

  • How to build a query to join on two tables without mapping

    I did Automatic mapping by the workbench Directofield mapping with the table and java object.
    Wanted to build a simple join query by joining on the same field on both the tables.Not the sql query through the toplink using expression builder.
    Please help.............
    Spent one full day for this................

    Thanks Don for the reply,sorry to bug you,but i need help.....
    SELECT A.AGNCY_C,
         A.TYPE_C,
         A.RESN_C,
         A.S_TYPE_C,
         A.SUB_ID_C,
         A.RY_C
    FROM RATING A, REF B
    WHERE A.ID_C = B._ID_C
    AND A.ALPHA_C = B.ALPHA_C
    AND A.EFF_D >= B.MATURITY_D
    This is the real query i was talking about.I did mapping automatically through the workbench,generated java classes also throught the workbench.
    Now they don't want to execute the raw sql.They wanted to get all the RATING objects with the where condition.
    So how to build a query by using toplink.
    tried your example
    ExpressionBuilder builder = new ExpressionBuilder();
    Expression creditRating = builder.getTable("RATING").getField("ID_C");
    Expression issue_ref = builder.getTable("REF").getField("ID_C");
    Expression join = creditRating.equal(issue_ref);
    I am getting java.lang.OutOfMemoryError
    error.
    I selected the option generate classes and descriptors
    from the tables (RATING,REF).,so it created the classes and dscriptors automatically.
    In Database script for the table RATING like this
    ALTER TABLE RATING ADD (
    CONSTRAINT RATING_F1 FOREIGN KEY (ID_C, ALPHA_C)
    REFERENCES REF (ID_C,ALPHA_C));
    I think when i generate descriptor automatically it is keeping this association.
    Please help me.........

Maybe you are looking for

  • Opening more than one PDF file at a time causes corrupted rendering

    For one of our users, opening any PDF file by itself works fine.  If any PDF file is open and he tries to open a second PDF, the computer hangs for 15-30 seconds and then when a second Adobe Reader window comes up, the document display incorrectly wi

  • Windows Media file write failure

    Help, I'm using a Gateway computer with Windows XP Professional OS, version 2002 and Service Pack3. It has Intel Core CPU, 6600 @ 2.40GHz, 2.41 GHz, 2.00 GB of RAM. I have both Premiere Pro CS3 and CS4 installed. There's 54.1 GB of free space on my H

  • How to Create Windows Firewall Predefined rules using Powershell

    Windows Firewall Predefined rules using Powershell Following commands are working some time however sometimes it's giving errors. Any help would be appreciated WORKING ==> Set-NetFirewallRule -DisplayGroup "File and Printer Sharing" -Enabled True  Se

  • Unable to Align the fields according to the Pre-Printed Cheque format

    Hi, I am having a requirement where I need to align the report output according to the Pr-printed Chekc Format which is loaded in the printer. In detail we have a pre-printed format of the cheque which will be loaded into the printer which includes t

  • Choosing Softcover Large Book

    Hi, I think I'm missing something here because I have gone through the entire process of setting up a large 8.5x11 book but just as I go to check out I only have the option for Hardcover. I am choosing- Theme: Modern Lines. Next I choose the book typ