How to do union.
hi all.
i want to create union and view of the following tables.can anyone help me out?I tried without union but counting is comming in wrong result.
thanks in advance.
SELECT PCD_IRS_ID,pcd_plt_id,PLM_PLT_ID,COUNT(pLM_policy_no),
SUM(DECODE(pcd_IRS_id,55,PCD_AMOUNT_LC,0)) TP,
SUM(DECODE(PCD_IRS_ID,56,PCD_AMOUNT_LC,0)) COMPUL
FROM TABLE1,TABLE2
where pcd_plt_id=plm_pLT_id
and pcd_plt_id in('U01','U02')
AND PCD_IRS_ID IN (55,56)
AND trunc(pcd_registry_date)=TRUNC(SYSdate)
AND TRUNC(PLM_REGISTRY_DATE)=TRUNC(SYSDATE)
GROUP BY PLM_PLT_ID,PCD_PLT_ID,PCD_IRS_ID
/ Its counting the policy no in whole tables but i want it count according sysdate.
sarah
hi
thanks for reply.
SELECT PCD_IRS_ID,pcd_plt_id,COUNT(pLM_policy_no),
SUM(DECODE(pcd_IRS_id,55,PCD_AMOUNT_LC,0)) TP,
SUM(DECODE(PCD_IRS_ID,56,PCD_AMOUNT_LC,0)) COMPUL
FROM UW_POL_PREM_FEES_DISC_COMMS,UW_POLICY_MASTERS
WHERE pcd_plt_id in('U01','U02')
AND PCD_IRS_ID IN (55,56)
AND trunc(pcd_registry_date)=TRUNC(SYSdate)
AND TRUNC(PLM_REGISTRY_DATE)=TRUNC(SYSDATE)
GROUP BY PLM_PLT_ID,PCD_PLT_ID,PCD_IRS_ID
UNION
SELECT PCD_IRS_ID,pcd_plt_id,COUNT(pLM_policy_no),
SUM(DECODE(pcd_IRS_id,55,PCD_AMOUNT_LC,0)) TP,
SUM(DECODE(PCD_IRS_ID,56,PCD_AMOUNT_LC,0)) COMPUL
FROM UW_POLICY_MASTERS,UW_POL_PREM_FEES_DISC_COMMS
WHERE pcd_plt_id in('U01','U02')
AND PCD_IRS_ID IN (55,56)
AND trunc(pcd_registry_date)=TRUNC(SYSdate)
AND TRUNC(PLM_REGISTRY_DATE)=TRUNC(SYSDATE)
GROUP BY PCD_PLT_ID,PCD_IRS_ID;let me give you separate tables then it will be ok and understandable.
SELECT CBR_ID,PLT_ID,SUM(SUM_PREM),SUM(COUNT_POL)
FROM
SELECT pcd_cbr_id CBR_ID, pcd_plt_id PLT_ID , sum(pcd_amount_lc) SUM_PREM,0 COUNT_POL
FROM UW_POL_PREM_FEES_DISC_COMMS----------------table1
where trunc(pcd_registry_date)=TRUNC(SYSDATE)
AND PCD_IRS_TYPE!=4
GROUP BY PCD_CBR_ID,PCD_PLT_ID
UNION
SELECT PLM_CBR_ID CBR_ID,PLM_PLT_ID PLT_ID,0 SUM_PREM, COUNT(PLM_POLICY_NO) COUNT_POL
FROM UW_POLICY_MASTERS--------------------------------table2
WHERE trunc(PLM_registry_date)=TRUNC(SYSDATE)
GROUP BY PLM_CBR_ID,PLM_PLT_ID)
GROUP BY CBR_ID,PLT_ID
ORDER BY CBR_ID,PLT_IDi want the result something like this.
CBR ID Plt_id count(policy_no) TP compul
55----- U01----- 2----------------------------according sysdate. $200 00
56----- u02 5----------------------------according sysdate. 00 $300but my result is comming wrong for Policy counting and its counting the both tables.
here is the result.
PCD_IRS_ID PCD_PLT_ID COUNT(PLM_POLICY_NO) TP COMPUL
55 u01 115 36390 0 THIS IS WRONG AND ITS COMMING 0(ZERO)
55 U01 5865 1855890 0
55 U01 8855 2802030 0
55 U01 14490 4585140 0
55 U01 29440 9315840 0
55 U02 91 52120 0
55 U02 4641 2658120 0
55 U02 7007 4013240 0
55 U02 11466 6567120 0
55 U02 23296 13342720 0
56 U01 24 0 70110 THIS IS WRONG ITS COMMING MORE AND ITS NOT ACCORDING SYSDATE AND ALSO SAME FOR OTHERS THATS WRONG.
56 U01 1224 0 3575610
56 U01 1848 0 5398470
56 U01 3024 0 8833860
56 U01 6144 0 17948160
56 U02 1 0 5400
56 U02 51 0 275400
56 U02 77 0 415800
56 U02 126 0 680400
56 U02 256 0 1382400sarah
Edited by: SaRaH on Jun 30, 2010 11:53 PM
Similar Messages
-
How to use union statement with declare & set function?
Hi Experts,
i have small query about how to use union statement with declare & set function?
Example as below :
DECLARE @name AS date
Declare @name2 AS date
/* SELECT FROM [2013].[dbo].[OINV] T0 */
/* WHERE */
SET @name = /* T0.DocDate */ '[%1]'
SET @name2 = /* T0.DocDate */ '[%2]'
select '2013',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2013.dbo.orct t1
inner join 2013.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2013.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2013.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2013].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between [%1] and [%2]
Union
/* SELECT FROM [2014].[dbo].[OINV] T0 */
/* WHERE */
SET @name = /* T0.DocDate */ '[%1]'
SET @name2 = /* T0.DocDate */ '[%2]'
select '2014',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2014.dbo.orct t1
inner join 2014.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2014.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2014.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2014].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between [%1] and [%2]You have to create stored procedure in SQL only .
Like u must have create for Crystal .
You can execute procedure in query manager but you have to enter parameter manually..
example
Exec @Test '20140101' '20140501'
Every time user has to enter it manually in yyyymmdd format in case of date parameters.
Example
Create Proc [@Test]
as begin
DECLARE @name AS date
Declare @name2 AS date
/* SELECT FROM [2013].[dbo].[OINV] T0 */
/* WHERE */
select '2013',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2013.dbo.orct t1
inner join 2013.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2013.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2013.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2013].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between @Name and @Name2
Union
/* SELECT FROM [2014].[dbo].[OINV] T0 */
/* WHERE */
select '2014',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2014.dbo.orct t1
inner join 2014.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2014.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2014.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2014].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between
between @Name and @Name2
end -
How to do UNION in an XML output
How to do union in an XML output
I have a requirement that I need to combine the results of 2 queries and get the final XML output. Typically this sound very easy and can b
be done with a simple UNION operator. But my query is a hierarchical query with CURSOR at the column level
For example
SELECT
EMPNOm
CURSOR(
SELECT
DEPTNO
FROM
DEPT
WHERE
EMPNO = :EMP_NO) AS DEPT
FROM
EMP
In oracle 9i UNION is not allowed in nested queries. One workaround is to populate the data from query one in a temp table and then from query 2 finally fetch the data from this temp table.
Can this requirement be fulfilled in any easirer way using SQLX or something else. Please suggest me .
Thank YouI'm afraid I have no idea what you are trying to achieve with Query you have posted. Can ypu provide some idea of what you would want the output of the query to look like given the data in the EMP and DEPT tables and a given value of EMPNP...
-
How to avoid unions in sql quries
Hi All,
I have an sql statement in which I am using unions to get the data from two tables with different conditions. how can avoid UNIONs in my query, which will increase performance. please suggest.
SQL Query is :
SELECT opt_url_path, locale
FROM urlregistry
WHERE master_assetid IN
(SELECT c.id FROM content_c c, content_cd cc
WHERE c.flextemplateid = cc.id AND cc.name = 'SoftwareDownload'
AND (c.PATH NOT LIKE '/auth%' AND c.PATH NOT LIKE '/gate%'))
UNION
SELECT opt_url_path, locale
FROM urlregistry
WHERE master_assetid IN
(SELECT c.id FROM content_c c, content_c_mungo cm
WHERE c.id = cm.cs_ownerid AND cm.cs_attrid =
(SELECT id FROM attribute WHERE name = 'Gated')
AND c.flextemplateid IN (SELECT id FROM content_cd WHERE name = 'Collateral')
AND cm.stringvalue = 'Yes'
AND (c.PATH NOT LIKE '/auth%'
AND c.PATH NOT LIKE '/gate%'))
UNION
SELECT PATH, locale
FROM bloburlregistry
WHERE master_assetid IN
(SELECT c.id FROM content_c c, content_c_mungo cm
WHERE c.id = cm.cs_ownerid AND cm.cs_attrid = (SELECT id FROM attribute WHERE name = 'Gated')
AND c.flextemplateid IN (SELECT id FROM content_cd WHERE name = 'Collateral')
AND cm.stringvalue = 'Yes'
AND (c.PATH NOT LIKE '/auth%'
AND c.PATH NOT LIKE '/gate%'))
Thank u.To increase performance you need to reduce the I/O. So when ever i tune a SQL the first thing i look for is that. If i have a table used multiple times i try to remove it and solve the required problem by just scanning the table once. But do to that we need to have good understanding of the data and there relation between tables. But we don't know anything about yours. Said that i came up with this.
select opt_url_path
, locale
from urlregistry
where master_assetid
IN
select c.id
from content_c c
left
join content_cd cc
on c.flextemplateid = cc.id
and (cc.name = 'SoftwareDownload' or cc.name = 'Collateral')
left
join content_c_mungo cm
on c.id = cm.cs_ownerid
and cm.cs_attrid =
SELECT id
FROM attribute
WHERE name = 'Gated'
and cm.stringvalue = 'Yes'
where c.PATH NOT LIKE '/auth%'
and c.PATH NOT LIKE '/gate%'
and (
cc.flextemplateid is not null or
cm.cs_owner_id is not null
union
select PATH
, locale
from bloburlregistry
where master_assetid IN
select c.id
from content_c c
, content_c_mungo cm
where c.id = cm.cs_ownerid
and cm.cs_attrid =
SELECT id
FROM attribute
WHERE name = 'Gated'
and c.flextemplateid IN
SELECT id
FROM content_cd
WHERE name = 'Collateral'
and cm.stringvalue = 'Yes'
and c.PATH NOT LIKE '/auth%'
and c.PATH NOT LIKE '/gate%'
This is a untested code. You can give this a try and see if it gives the expected output and also if the performance improves. -
How to use 'UNION' between two different databaseservers
Hello,
Could someone help me out. I am trying to find out if and how to use 'UNION' between two different databaseservers.
We have 2 different queries, each queries on a different database; one MySQL the other MSSQL.
Could someone tell me how to use 'UNION' between thes 2 queries?
Thanks in advance,
Samir BenallaHello
You may use openrowset statement, (OPENROWSET (Transact-SQL))., but before you use this, you must configure your server
sample:
SELECT a.*
FROM OPENROWSET('SQLNCLI', 'Server=Seattle1;Trusted_Connection=yes;',
'SELECT GroupName, Name, DepartmentID
FROM AdventureWorks2012.HumanResources.Department
ORDER BY GroupName, Name') AS a
UNION
SELECT GroupName, Name, DepartmentID
FROM AdventureWorks2012.HumanResources.Department
ORDER BY GroupName, Name
With this you can define a connection using native client to server Seattle1, and execute a query there, The results will be spooled on your server.
Connectionstring
Server=[SERVER_NAME];datasource=[YOUR DATABASE NAME];user_id=sa;password=sapassword'
if you use FQDN on your Query, than the datasource parameter in connection string can be letf out.
Regards
János.
take care of performance, it can be very slow, -
How to create Union Time Pool using accruals ???
Hi,
My client has a unique requirement of creating a Union Time Pool i.e. at the begining of each year the client will have 'X' amount of hours assigned to the pool. Employees under Union Contract will then be eligible to take any leave hours from that time pool as long as they are approved by there supervisor. Now, if we create an element pertaining to the special leave based on Time Pool, then an entry can be made at timecard level and the number of hours remaining can be determined.
But, this pool is not employee based hence the Hours remaining calculation for the Time Pool is irrespective of any assignment rather its organization/GRE based. How do we implement this using Accruals?
The client wants to view the balances in the Time Pool within the system. How can that be achieved?
I understand Accruals Caculation and balances is totally assignment based, how can that be made for GRE/Organization based?
Any help or suggestions will be highly appreciated.
Thanks,
UjjalHi,
This is a really interesting scenario.. what are you trying to do
1. Find a place where the common pool details can be entered at the start of the year
2. The accrual process should deduct from this pool
3. On accrual balance for the union should be displayed.
let us evaluate what are things that cannot be used
1. Elements can be initialized as the leave pool is for a group of people whereas elements are for an assignment
2. Balances cannot be used for same reason
so what are the options that we have..
1. Store the pool in a lookup that can be created based on a bg or gre (use dff) and use the date fields of the lookup to simulate date track feature in HRMS. This way you would be able to enter values for every year for every bg / gre. Also enable another dff segment to store the balance leave in the pool. This field can be hidden.
2. You can refer lookup in the accrual rules and evaluate the pool for processing the leave
3. Customize the form / page to display the remaining pool from based on the person's detail and the lookup. This customization could be complicated instead you can maintain a dff in person/ asg table and write a custom process that will populate the pool balance for all people.
This one of the suggestion I can give you.. there could be other options that you can evaluate.. but its not going to be simple..
I hope this helps you.
Regards,
Vikash -
How to implement Union and Join operations in OBIEE
Hi all,
Am new to OBIEE. Can some one tell me the right place to create Union and Joins in OBIEE....
Do i need to create Union or Join in Oracle(DB level) or do i have the option of creating Union/Join in Physical layer or BMM layer. I tried creating a union in Physical layer,but when i check the the data in presentation layer,i see only data from 1st table.
Thanks you
PraveenUnion - in the physical layer when creating new physical table/table type select:
Example:
select 1 as id from dual union all
select 2 as id from dual
Joins - You create them in the physical layer (FK, complex) and in the BMM (complex).
You don't need to create joins in the database.
Regards
Goran
http://108obiee.blogspot.com -
How to perform Set operations in ODI?
Can anybody suggest me how to perform a set operations in ODI?
Hi ,
May be the below threads helpful for u....
UNION operation in ODI
How to use Union, Union all, MINIUS in ODI
Thanks. -
HOW CAN I UNION IN SQL MULTIPLE TIMES. I MAM TRYING TO USE UNION MULTIPLE TIMES SOME TIME IT WORKS BUT SO MANY OFTEN IT DOSE'NT AND ALSO SOME TIME IT GIVE'S THE WRONG RESULT
ANY REASONOFTEN IT DOSE'NT AND ALSO SOME TIME IT GIVE'S THE WRONG RESULT May be because you are doing it the wrong way. If you are learning about union, it may confuse you initially, but try understanding the way union works and figure out where you are doing a mistake.
-
ODI 10g Union,Union All,Minus
Hello,
I have to use union,union all or minus set on ODI 10.But it doesn't have uninon,union all minus data set like in ODİ 11.How can ı use union statement in odi 10 g?For example I have to union 6 table in odi 10g.How it can be ?
Thnx a kotThx a lot Jerome .it works
I have one more question:
This select captured changed datas.I will delete dataas which returns from this select.And then I will insert new datas.
I added to IKM COntrol append a new step like this:
delete from <%=odiRef.getTable("L","TARG_NAME","A")%> T WHERE (<%=odiRef.getTargetColList("", "t.[COL_NAME]", ", ", "\n", "UK")%>) in
SELECT PK_ID
FROM <%=odiRef.getFrom()%>
WHERE (1=1)
<%=snpRef.getJoin()%>
<%=snpRef.getFilter()%>
<%=snpRef.getJrnFilter()%>
<%=snpRef.getGrpBy()%>
<%=snpRef.getHaving()%>
/*commit*/
I selected "UK" from target.
But I dont know that it works true.I selected PK_ID from source but which PK_ID Will I select?When targets UK is equal to source UK(PK_ID) then these datas will be deleted.Changed datas will be inserted.How can I modify this step?İs there any solution to do this step?Can I get dynamicly PK_ID?
Could you help me ?
Best Regards
Thanks -
We are working on how to implement union command in an interface
Has anyone done that.
Example: If I want to implement the following through one interface.
select * from table A
union all
select * from table BHi,
Hope this will help you,
Re: Union & Union All
Thanks,
Guru -
Union All is not bring the second part columns to the report
I have 5 groups of series of Select statements and then I made a UNION ALL after the first group. Now it does run correctly and displays the output but it does not assign the second group' s field names.
For example. I am greatly abridging
Completed the SQL's needed to mimic a IBM i display screen. There are 5 product groups making up the screen. I was hoping to have one large Command SQL having the 5 SQLs using UNION ALL. This does 'compile' as a Command. However, it does only brings in the first part fields not the second. So this field is not included in the list of fields tree for COMMAND. PROGR2R2PST,
Is there something not correct how doing the UNION ALL? OUTPUT assigns the column name
of the first group to the second group. HLDGR1PUN 21454 87273
so if i wanted to have one large SQL with union ALLs, it wont work. is there something other than UNION ALL I should use? One idea is if I can have 5 commands to my disposal. I guess using subreports you can but it will be too slow.
SELECT
count(*) as PROGR1PST,
SELECT COALESCE(SUM(OdQty#),0)
FROM ASTCCDTA.OEORH48,ASTCCDTA.TRNSTAT2,ASTDTA.OEORD1
WHERE OHCOM# = TSCOM# AND OHORD# = TSORD# AND OHCOM# = ODCOM# AND OHORD# = ODORD#
AND TSSTAT IN('AEP','BGE')
AND OHORDT IN('RTR','INT','SAM')
AND OHREQD < replace(char(current date, iso), '-', '')
AND OHHLDC = ' '
AND ODPRLC = 'ENG'
AND substr(odprt#,1,5) <> 'NOENG' AND OHORD# in(SELECT a.TSORD# FROM ASTCCDTA.TRNSTAT2 a
WHERE a.tsstat IN('AEP','BGE','EAS','REL','STP'))
) AS PROGR1PUN,
SELECT count(*)
FROM ASTCCDTA.OEORH48,ASTCCDTA.TRNSTAT2,ASTCCDTA.OETRA99
WHERE OHCOM# = TSCOM# AND OHORD# = TSORD#
AND (otCOM# = OHCOM# AND OTORD#= OHORD# AND ottrnc = 'AQC')
AND TSSTAT IN('AEP','BGE')
AND OHORDT IN('RTR','INT','SAM')
AND OHREQD = replace(char(current date, iso), '-', '') AND OHHLDC = ' ' AND OHORD# in(SELECT a.TSORD# FROM ASTCCDTA.TRNSTAT2 a
WHERE a.tsstat IN('AEP','BGE','EAS','REL','STP'))
) AS PROGR1TOD,
etc..
UNION ALL
SELECT
count(*) as PROGR2R2PST,
(SELECT COALESCE(SUM(OdQty#),0) FROM ASTCCDTA.OEORH48,ASTCCDTA.TRNSTAT2,ASTDTA.OEORD1
WHERE OHCOM# = TSCOM# AND OHORD# = TSORD# AND OHCOM# = ODCOM# AND OHORD# = ODORD#
AND TSSTAT IN('AEP','BGE')
AND OHORDT IN('CUS','CIN','SMC','COC','DON')
AND OHREQD < replace(char(current date, iso), '-', '')
AND OHHLDC = ' '
AND ODPRLC = 'ENG'
AND substr(odprt#,1,5) <> 'NOENG' AND OHORD# in(SELECT a.TSORD# FROM ASTCCDTA.TRNSTAT2 a
WHERE a.tsstat IN('AEP','BGE','EAS','REL','STP'))
) AS PROGR2PUN,hi Paul,
a union combines record sets like this
field1 field2
1 2
union
field3 field4
2 8
will produce
field1 field2
1 2
2 8
note that there are no more field3 & field4 names. that's the way a union works.
if you need separate fields for your other values then you would need to use sub-queries instead. to do that delete "UNION ALL " and create sub-queries with anything that is beneath that statement. -
Again select statement.
hi all
i am having a problem in result,the following query is giving me wrong result.i want the result something like this.
PLD_ID count TP Compul
U01 259 3434234 37676454
U02 184 533234 76867676but the result is comming something like this which is wrong.
PLT_ID SUM(COUNT_POL) TP COMPUL
U01 259 0 0
U01 0 77660 125507
U02 184 0 0
U02 0 184943 484733here is the query.
SELECT PLT_ID,SUM(COUNT_POL),tp,compul
FROM
SELECT pcd_plt_id PLT_ID , sum(pcd_amount_lc) SUM_PREM,0 COUNT_POL,
SUM(DECODE(pcd_IRS_id,55,PCD_AMOUNT_LC,0)) TP,
SUM(DECODE(PCD_IRS_ID,56,PCD_AMOUNT_LC,0)) COMPUL
FROM table1
where trunc(pcd_registry_date)=TRUNC(SYSDATE)
AND PCD_PLT_ID IN ('U01','U02')
AND PCD_IRS_ID IN (55,56)
GROUP BY PCD_PLT_ID
UNION
SELECT PLM_PLT_ID PLT_ID,0 SUM_PREM, COUNT(PLM_POLICY_NO) COUNT_POL,
0 tp,
0 compul
FROM table2
WHERE trunc(PLM_registry_date)=TRUNC(SYSDATE)
and plm_plt_id in ('U01','U02')
GROUP BY PLM_PLT_ID)
GROUP BY plt_id,compul,tp
ORDER BY PLT_IDany help would be greatly appreciated.thanks in advance.
sarahYou can't or won't get what you desire using UNION so eliminate that
Re: how to do union.
Re: select statement,view and union.
Edited by: sb92075 on Jul 5, 2010 11:56 AM -
Regarding joining two internal tables
Hi All,
Tell me how to use 'UNION' in different ways.
Thank you,
RohitHi,
If its internal table joining then best is to use APPEND LINES.... statement.
You can also append internal tables to index tables using the following statement:
APPEND LINES OF itab1 TO itab2.
This statement appends the whole of ITAB1 to ITAB2. ITAB1 can be any type of table, but its line type must be convertible into the line type of ITAB2.
When you append an index table to another index table, you can specify the lines to be appended as follows:
APPEND LINES OF itab1 [FROM n1] [TO n2] TO itab2.
n1 and n2 specify the indexes of the first and last lines of ITAB1 that you want to append to ITAB2.
This method of appending lines of one table to another is about 3 to 4 times faster than appending them line by line in a loop. After the APPEND statement, the system field SY-TABIX
contains the index of the last line appended. When you append several lines to a sorted table, you must respect the unique key (if defined), and not violate the sort order. Otherwise, a runtime error will occur.
thanx. -
Hi all,
I have got two tables in oracle,how can i append two tables? i wantr a new table with both table appended,
can anyone clearly explain me how to use UNION,can anyone of you please explain me using code?
Thanks
Mike.>
I have got two tables in oracle,how can i append two tables? i wantr a new table with both table appended,
can anyone clearly explain me how to use UNION,can anyone of you please explain me using code?CREATE MyNewTable AS (SELECT * FROM MyOldTable1);
INSERT INTO MyNewTable VALUES( SELECT * FROM MyOldTable2);
Tables must have the same structure.
Of you could try
CREATE MyNewTable AS ((SELECT * FROM MyOldTable1) UNION ALL (SELECT * FROM MyOldTable2))
UNION instead of UNION ALL will eliminate duplicates.
Note. not tested.
HTH.
Paul...
When asking database related questions, please give other posters
some clues, like OS (with version), version of Oracle being used and DDL.
Other trivia such as CPU, RAM + Disk configuration might also be useful.
The exact text and/or number of error messages is useful (!= "it didn't work!"). Thanks.
Furthermore, as a courtesy to those who spend time analysing and attempting to help,
please do not top post and do try to trim your replies!
Mike.
Maybe you are looking for
-
I live in UAE but have been accessing the US ITunes Store. With latest upgrade, can no longer do that from a foreign country. If I open a UAE ITunes account, will I have to repurchase items I already purchased from US account? Any way to link the
-
Stand-by / sleep mode not working when USB is connected
Hello! When the USB cable from my 24" LED Cinema Display is connected to my new Mac Pro 2,66 GHz Quad-Core, the stand-by / sleep mode does not work correctly: the Mac Pro goes to sleep normally, then the LED behind the on-/off-button flashes one time
-
Invoice Descriptions are not carried to GL
Hi In our R11 the Invoice Description in AP are carried to GL when we run the Payables Transfer to GL. But in R12, im wondering why is it the Invoice Description that we had in Payables Module are no longer copied to GL Journal Description Column. In
-
Exception while creating Database in oracle10g Solaris 10 using DBCA
hi, While i am creating a DB using DBCA in oracle_home/bin directory i am getting the following mentioned exception. Exception in thread "main" I have set the DISPLAY to the local machine(DISPLAY=LocalMachineIp:0.0 ; export DISPLAY) After this i have
-
Get second-highest element in hierarchy
It's Friday afternoon and my brain isn't working well, and some of you people I'm sure will have the answer in a flash.... I have a typical hierarchical table, here's an example below; with codes as (select 17 icode, -1 parent_code,'Group Service