Help required in writing an sql to fetch the the difference of the data.
Hi Gurus,
Could some one help me in writing an sql to pull data the difference between two same structured tables from two different database and to store that data in an temperory table.
many many thanks in advance
Lets say you have two db SOURCE and DEST
SOURCE is the DB that you have Logged in into. Now you do the following.
1. Createa DBLink to DEST database.
2. Check if the DBLink works properly.
3. Then execute the following sql.
select <column_list> from <table_name>
minus
select <column_list> from <table_name>@<dblink>
union all
select <column_list> from <table_name>@<dblink>
minus
select <column_list> from <table_name>
Similar Messages
-
Help required in writing an sql querry
Hi guys,
Could any one hlep me out in writing an sql querry for the below requirement.
the requirement is: for a perticular ID if we have different names then we need to get it out as multiple else the name itselef. I have given the sample input and the expected output.
ID Name
1 A
1 B
2 F
2 F
3 C
4 D
4 E
Out put should look like
ID Name
1 Multiple
2 F
3 C
4 Multiple
Thanks in advance
Shylender.
Edited by: 959345 on Nov 22, 2012 10:13 PMMay be this:
WITH t AS
(SELECT 1 id, 'A' str FROM DUAL
UNION ALL
SELECT 1, 'B' FROM DUAL
UNION ALL
SELECT 2, 'F' FROM DUAL
UNION ALL
SELECT 2, 'F' FROM DUAL
UNION ALL
SELECT 3, 'C' FROM DUAL
UNION ALL
SELECT 4, 'D' FROM DUAL
UNION ALL
SELECT 4, 'E' FROM DUAL),
t1 AS
(SELECT id,
CASE
WHEN COUNT (DISTINCT str) OVER (PARTITION BY id) > 1 THEN
'MULTIPLE'
ELSE
str
END
str
FROM t)
SELECT id, str
FROM t1
GROUP BY id, str
ORDER BY 1;Cheers,
Manik. -
What are the functional differences between the iPhone and the iPod Touch, barring of course the differences in service requirements.
For one, their form factors are slightly different as the iPhone has a bit more squarish body whereas the iPod Touch has a tapered back to it.
The iPhone also has much better front and rear cameras. Exact details as to the difference in megapixels depends on whether or not you talking about the iPhone 4 or 4S. If you would like to get more details, you can always view
each models specs on Apple's online store.
See here for a better explanation.
http://en.wikipedia.org/wiki/IPod_Touch#Comparison_to_the_iPhone
I'm sure others will chime in with other things as well.
B-rock -
Hi All,
We have a query which is taking hell lot of time in production due to Full Table Scan on the table AP_ACCOUNTING_EVENTS.
We have then tried to force the index AP_ACCOUNTING_EVENTS_N1 on the query by applying hints.
Now the table is doing a range scan using index AP_ACCOUNTING_EVENTS_N1.
But to my surprise, the query with hints is taking even more time than that of query without hint.
Database: 10.0.2
and Application : 11.5.10.2
PFB the query:
SELECT api.invoice_id,
SUBSTR(pov.segment1, 1, 5) supplier_code,
DECODE(pov.segment1,
'A',
SUBSTR(api.attribute7, 1, 20),
SUBSTR(pov.vendor_name, 1, 20)) supplier_name,
MIN(TRUNC(aae.creation_date)) approval_date
FROM po_vendors pov, ap_invoices api, ap_accounting_events aae
WHERE api.payment_status_flag = 'Y'
AND api.source not in ('A', 'B', 'C')
AND aae.source_table = 'AP_INVOICES'
AND aae.creation_date >= sysdate - 2
AND aae.creation_Date < sysdate
AND aae.accounting_event_id = aae.ACCOUNTING_EVENT_ID
AND pov.vendor_id = api.vendor_id
AND aae.source_id = api.invoice_id
GROUP BY api.invoice_id,
SUBSTR(pov.segment1, 1, 5),
DECODE(pov.segment1,
'A',
SUBSTR(api.attribute7, 1, 20),
SUBSTR(pov.vendor_name, 1, 20))
Kindly Help.
Thanks,Tuning request
Take a look at the
When your query takes too long ...
HOW TO: Post a SQL statement tuning request - template posting -
Help required in writing PCR's
Hi All,
Update on this is highly appreciable and points will be rewarded.
Thanks & Regards,
surya
Hi All,
To calculate OT as per the Client requirement two PCR's needs to be wriiten.
1. OT should not be paid if it is less than 30 mins.
2. OT should be calculated as follows:
(basic2/26/8no. of hours).
Your help in this regard is highly appreciable.
Thanks & Regards,
Surya
Edited by: Surya Prakash Kanuru on Sep 15, 2008 9:55 AMHi,
No need to write to 2 PCR ,with one pcr itself it can be calculated . Here maintain overtime hrs in 15 infotype ,such that overtime hrs will be stored in a wage type say 9ovt .
Pcr can be build in this way
90vt
num = 90vt(where overtime hrs will be transfered to num)
num?0.5
< ( if the hrs is 30 mins )
your logic
= (30 mins )
logic calc
> (30 min)
amt = 1001 (basic wage type)
amt = 1001 div 2
some calc
div ana (for dividing with the no of hrs and passing the overtime value to the amt)
addwt *
Hope it helps u
Regards,
Prince Elvis -
Help required in writing And Reading Xml From Database
Hi
i m new to java.
i m facing problem while writing Xml file from Mysql Database in java i m using the WebRowSet
and also for Reading WebRowSet
after reading the Xml i have to save this in Database
(required source code)
is there any one to help me in this way
regards
aamirshadab_think_globally wrote:
{noformat}*hi everybody,
please send me a ajax with jsp application
suppose i enter a word in text area ajax will populate/suggest all string from database ,who started
from that entering character(s).like a google string search.
please send full source code
*{noformat}how about you do it yourself? -
Help Required -- Can we use SQL Query to READ data from SAP MDM Tables
Hi All,
Please help.........
Can we use SQL Query to READ(No Creation/Updation/Deletion just Read) Data from SAP MDM tables directly, without using MDM Syndicator.
Or direct SQL access to SAP MDM tables is not possible. Only through MDM Syndicator can we export data.
Thanks in Advance
RegardsAll the tables you create in Repository comes under A2i_CM_Tables in Database named as your repository name. So the tables names are fields of table A2i_CM_Tables. Now i tried it but cant make it.
Now, I dont think its possible to extract all fields in tables and there values using select query. May be pure sql guy can do that or not.
But there is no relation of data extraction and syndicator. Data is viewed in Data Manager. and you can also store data in a file from DM also.
BR,
Alok -
Help needed on writing a SQL query
Here is my table that shows records of 3 ORDER_ID (10, 20 and 30). All I need to do is, pick the first record of each order_id and check the event_id, if the event_id is same for the next record, ignore it, else show it and ignore rest all records for that order_id. This way my query output will show only two records for each ORDER_ID. Query should produce records that are in BOLD in the sample data. (Database - 11g)
Thanks for your help in advance
ORDER_ID EVENT_ID EVNT_DATE STATE_CODE
*10 16937555 20100212 COMPLETE*
10 16937555 20100212 ACTIVE
*10 16308004 20100129 OCCURRED*
10 16131904 20100125 ACTIVE
10 16270684 20100128 OCCURRED
10 14899116 20091213 ACTIVE
10 16085672 20100123 COMPLETE
10 16085673 20100123 OCCURRED
10 14899119 20100123 COMPLETE
10 14899120 20100123 COMPLETE
*20 17134164 20100223 COMPLETE*
20 17134164 20100223 ACTIVE
20 17134164 20100223 STARTED
*20 15479131 20100105 OCCURRED*
20 15478409 20100105 OCCURRED
20 15478408 20100105 ACTIVE
20 15119404 20100105 COMPLETE
20 14346123 20091129 ACTIVE
20 15467821 20100104 OCCURRED
20 14346125 20091216 COMPLETE
20 14346126 20091215 COMPLETE
20 14346126 20091214 COMPLETE
*30 18814670 20100412 COMPLETE*
30 18814670 20100412 ACTIVE
*30 18029509 20100320 OCCURRED*
30 16853720 20100211 ACTIVE
30 17965764 20100319 OCCURRED
30 16386708 20100211 COMPLETE
30 16804451 20100211 OCCURRED
30 15977897 20100121 ACTIVE
Edited by: sarvan on Aug 12, 2011 7:16 AMtry this [Not fully tested]
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
Elapsed: 00:00:00.00
SQL> SELECT *
2 FROM (SELECT order_id, event_id, evnt_date, state_code, next_evntid,
3 ROW_NUMBER () OVER (PARTITION BY event_id ORDER BY NULL)
4 AS rownm
5 FROM (WITH t AS
6 (SELECT 10 AS order_id, 16937555 AS event_id,
7 20100212 AS evnt_date, 'COMPLETE' AS state_code
8 FROM DUAL
9 UNION ALL
10 SELECT 10, 16937555, 20100212, 'ACTIVE'
11 FROM DUAL
12 UNION ALL
13 SELECT 10, 16308004, 20100129, 'OCCURRED'
14 FROM DUAL
15 UNION ALL
16 SELECT 10, 16131904, 20100125, 'ACTIVE'
17 FROM DUAL
18 UNION ALL
19 SELECT 10, 16270684, 20100128, 'OCCURRED'
20 FROM DUAL
21 UNION ALL
22 SELECT 20, 17134164, 20100223, 'COMPLETE'
23 FROM DUAL
24 UNION ALL
25 SELECT 20, 17134164, 20100223, 'ACTIVE'
26 FROM DUAL
27 UNION ALL
28 SELECT 20, 17134164, 20100223, 'STARTED'
29 FROM DUAL
30 UNION ALL
31 SELECT 20, 15479131, 20100105, 'OCCURRED'
32 FROM DUAL) -- End of test data
33 SELECT order_id, event_id, evnt_date, state_code,
34 LEAD (event_id, 1, 0) OVER (PARTITION BY order_id ORDER BY NULL)
35 AS next_evntid
36 FROM t)
37 WHERE event_id = next_evntid)
38 WHERE rownm <= 2
39 /
ORDER_ID EVENT_ID EVNT_DATE STATE_CO NEXT_EVNTID ROWNM
10 16937555 20100212 COMPLETE 16937555 1
20 17134164 20100223 COMPLETE 17134164 1
20 17134164 20100223 ACTIVE 17134164 2
Elapsed: 00:00:00.00
SQL> PS - You should seriously think about ordering the data before you do this kind off operations.
Edited by: Sri on Aug 12, 2011 9:12 AM -
Help required in writing the query
I have the following level accounts
10000
11000
11100
11101
11200
11201
12000
12100
12101
12102
12103
20000
21000
21100
21101
22000
22101
21200
21201
I have to take the amount of the child account and sum it to the parent account as below:
11100 = 11101 + 11102 - 11103+.........
11000 = 11100 + 11200 + 11300+.........
10000 = 11000 + 12000 + 13000+.........
21100 = 21101 + 21102 - 21103+.........
21000 = 21100 + 21200 + 21300+.........
20000 = 21000 + 22000 + 23000+.........
Please help...
Thanks in advance.SQL> with t as (
2 select 10000 ACCOUNT, NULL BEG_BAL, NULL END_BAL from dual union all
3 select 11000,NULL,NULL from dual union all
4 select 11100,NULL,NULL from dual union all
5 select 11101,1750.00,4150.00 from dual union all
6 select 11102,1550.00,3150.00 from dual union all
7 select 11103,1650.00,3200.00 from dual union all
8 select 11200,NULL,NULL from dual union all
9 select 11201,800.00,1250.00 from dual union all
10 select 11202,1550.00,3150.00 from dual union all
11 select 12000,NULL,NULL from dual union all
12 select 12100,NULL,NULL from dual union all
13 select 12101,1200.00,5000.00 from dual union all
14 select 12102,1500.00,3000.00 from dual union all
15 select 12103,1550.00,2750.00 from dual union all
16 select 20000,NULL,NULL from dual union all
17 select 21000,NULL,NULL from dual union all
18 select 21100,NULL,NULL from dual union all
19 select 21101,2000.00,6500.00 from dual union all
20 select 21102,1500.00,3500.00 from dual union all
21 select 21103,1750.00,3550.00 from dual union all
22 select 22000,NULL,NULL from dual union all
23 select 22100,NULL,NULL from dual union all
24 select 22101,1550.00,3550.00 from dual union all
25 select 22102,2550.00,5550.00 from dual union all
26 select 21200,NULL,NULL from dual union all
27 select 21201,2550.00,6500.00 from dual union all
28 select 21202,3550.00,7500.00 from dual
29 )
30 select account,
31 beg_bal,
32 end_bal,
33 sum(beg_bal) over(order by account range between current row and grouping_window follow
ing) group_beg_bal,
34 sum(end_bal) over(order by account range between current row and grouping_window follow
ing) group_end_bal
35 from (
36 select t.*,
37 case
38 when account / 10000 = trunc(account / 10000) then 9999
39 when account / 1000 = trunc(account / 1000) then 999
40 when account / 100 = trunc(account / 100) then 99
41 when account / 10 = trunc(account / 10) then 9
42 else 0
43 end grouping_window
44 from t
45 )
46 order by account
47 /
ACCOUNT BEG_BAL END_BAL GROUP_BEG_BAL GROUP_END_BAL
10000 11550 25650
11000 7300 14900
11100 4950 10500
11101 1750 4150 1750 4150
11102 1550 3150 1550 3150
11103 1650 3200 1650 3200
11200 2350 4400
11201 800 1250 800 1250
11202 1550 3150 1550 3150
12000 4250 10750
12100 4250 10750
ACCOUNT BEG_BAL END_BAL GROUP_BEG_BAL GROUP_END_BAL
12101 1200 5000 1200 5000
12102 1500 3000 1500 3000
12103 1550 2750 1550 2750
20000 15450 36650
21000 11350 27550
21100 5250 13550
21101 2000 6500 2000 6500
21102 1500 3500 1500 3500
21103 1750 3550 1750 3550
21200 6100 14000
21201 2550 6500 2550 6500
ACCOUNT BEG_BAL END_BAL GROUP_BEG_BAL GROUP_END_BAL
21202 3550 7500 3550 7500
22000 4100 9100
22100 4100 9100
22101 1550 3550 1550 3550
22102 2550 5550 2550 5550
27 rows selected.
SQL> SY. -
Hi SDNers,
I have a requirement to write UDF, can anybody help me in acheiving the code.
Requirement:-
If I am getting 5 as my input to UDF, I need to generate five 001's to my output of UDF.
I tried to loop the input and used result.addValue("001"); but not working.
Please help in getting java logic for this udf.
Thanks
Jayaram.GHi Luis,
Thanks for your quick response.
I am using context in my udf.
My code is like this.
for(int i=0;i<var1.length;i++)
result.addValue("001");
As I am getting 5 as input and I am using Var1.length, the udf is generating only one 001. But I need five 001.
Regards,
Jayaram.G -
Help required in writing a query
hi
Consider a table (ShogenValue) with following data:
Model_Id header_id Serial_no shogen_no si_val
4329 1 40001 A0001 1
4329 1 40001 B0001 2
4329 1 50300 B0001 3
4329 1 40001 C0001 4
4329 1 50300 C0001 5
4329 1 60001 C0001 6
Select
si_val
From
ShogenValue
Where
model_id = 4329
And
header_id = 1
And
serial_no = '60001'
Is it possible to write a modified version of above query which will bring the following result:
Model_Id header_id Serial_no shogen_no si_val
4329 1 40001 A0001 1
4329 1 50300 B0001 3
4329 1 60001 C0001 6
Meaning if a record exists for a particular shogen_no (Shogen_no C0001 has value corrosponding to '60001' in above query), pick it up, if it
does not exist (Shogen_no B0001 does not have value corrosponding to '60001' in above case) then pick a record with one level less serial number ('50300' in above case) and so on.
Thanx
Regards
Omer ImtiazThis should help, although it will probably not perform. Try it and see what the plan for it is.
SELECT
FROM
shogenvalue sv,
(SELECT
max(serial_no) serial_no_max,
shogen_no
FROM
shogenvalue
WHERE
model_id = 4329
AND header_id = 1
AND serial_no <= '60001'
GROUP BY
shogen_no
) svm
WHERE
sv.serial_no = svm.serial_no_max
AND sv.shogen_no = svm.shogen_no
;HTH,
Lennert -
Help Required in writing a small program
Create ajava program to manage vehicles.the class vehicle must have five attributes
maybe he cant figure out what five attributes a
vehicle class can have :-)boolean hasSpinnningRims;boolean isPimped;int noOf Wheels;
public final int LEFT_IN_MANCHESTER = 0;
public final int LEFT_IN_BRADFORD= 1;
public final int DELL_BOY = 3; -
Please help me in writing the SQL
Hi,
I am new to oracle.. Can you please help me in writing a SQL
I have a table which has the following columns
Start_date m1 ---- Start month of each quarter (Jan,Apr,Jul,oct)
end_date m3---- End month of each quarter
m1_start_date,
m1_end_date,
m2_start_date,
m2_end_date,
m3_start_date,
m3_end_date,
M1_act_rev,
m2_act_rev,
m3_act_rev
If a user selects the dates from Jan,2011 to Jun, 2011
I should get the aggregate of the revenues (m1+m2+m3+m1+m2+m3)Hi Gurus,
Will this work
select
b.DISTRICT_NAME,
count(c.CONTRACT_NUMBER),
sum(C.M1_ACT_REV),
sum(C.M2_ACT_REV),
sum(C.M3_ACT_REV),
sum(C.M1_EXP_PRICE),
sum(C.M2_EXP_PRICE),
sum(C.M3_EXP_PRICE)
from
clm_mn_compliance_data c,
CLM_MN_CUSTOMER_ALIGNMENT_DATA b
where
((m1_start_date between '01-01-2011' and '03-31-2011' ) and (m1_end_date between '01-01-2011' and '03-31-2011')) or
((m2_start_date between '01-01-2011' and '03-31-2011' ) and (m3_end_date between '01-01-2011' and '03-31-2011')) or
((m3_start_date between '01-01-2011' and '03-31-2011' ) and (m3_end_date between '01-01-2011' and '03-31-2011')) and
b.CUSTOMER_ID = C.CUST_CTRT_ID
group by
B.DISTRICT_NAME; -
Why it is required to run adupdlib.sql after cloning
Hello All,
Every week we need to refresh oracle EBS [11.5.10] from prod.
As per the steps after the restoration of database [10g R2] for , why every time it is required to run adupdlib.sql so at dbTier?
What actually the scripts does? What will happen if at all I will not execute the script?
Please suggest.
Thanks-
Puser9093772 wrote:
Hello All,
Every week we need to refresh oracle EBS [11.5.10] from prod.
As per the steps after the restoration of database [10g R2] for , why every time it is required to run adupdlib.sql so at dbTier?
What actually the scripts does? This script update the libraries with the correct file specifications (check the contents of the script for details).
for 11i it updates .so library files version
What will happen if at all I will not execute the script?libraries wont get updated
please log a SR with oracle to know more about the scripts
:) AppsMasti ;)
sharing is Caring -
Help on writing pl/sql stored procedure to accept input in xml format
Hi All,
I need to write a pl.sql stored procedure which would be getting the input as an xml.
The requirement is that xml data recieved in below fashion needs to be inserted to 3 different tables.
The tags under the root node directly needs to be inserted into Table1
The tags under the first element of the root node needs to be inserted into Table2
Can anybody help me on how to write a stored procedure which could take up the below xml as input and insert the data received into 3 different tables.
Any sample code.pointers to achieve this could be of great help.
The structure of the xml would be as follows:
<AssemblyProduct>
<AssemblyHeader>
<Name></Name>
<AssemblyId></AssemblyId>
<ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
<ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
<ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
</AssemblyHeader>
<AssemblyHeader>
<Name></Name>
<AssemblyId></AssemblyId>
</AssemblyHeader>
<AssemblyHeader></AssemblyHeader>
<ApplicationId></ApplicationId>
<ApplicationName></ApplicationName>
<ApplicationValidFrom></ApplicationValidFrom>
<ApplicationValidTo></ApplicationValidTo>
</AssemblyProduct>Well you could write your procedure to accept a parameter of XMLTYPE datatype and then use that value in a query inside the procedure to break the data up as required using something like XMLTABLE e.g.
-- Nested repeating groups example:
WITH t as (select XMLTYPE('
<RECSET>
<REC>
<COUNTRY>1</COUNTRY>
<POINT>1800</POINT>
<USER_INFO>
<USER_ID>1</USER_ID>
<TARGET>28</TARGET>
<STATE>6</STATE>
<TASK>12</TASK>
</USER_INFO>
<USER_INFO>
<USER_ID>5</USER_ID>
<TARGET>19</TARGET>
<STATE>1</STATE>
<TASK>90</TASK>
</USER_INFO>
</REC>
<REC>
<COUNTRY>2</COUNTRY>
<POINT>2400</POINT>
<USER_INFO>
<USER_ID>3</USER_ID>
<TARGET>14</TARGET>
<STATE>7</STATE>
<TASK>5</TASK>
</USER_INFO>
</REC>
</RECSET>') as xml from dual)
-- END OF TEST DATA
select x.country, x.point, y.user_id, y.target, y.state, y.task
from t
,XMLTABLE('/RECSET/REC'
PASSING t.xml
COLUMNS country NUMBER PATH '/REC/COUNTRY'
,point NUMBER PATH '/REC/POINT'
,user_info XMLTYPE PATH '/REC/*'
) x
,XMLTABLE('/USER_INFO'
PASSING x.user_info
COLUMNS user_id NUMBER PATH '/USER_INFO/USER_ID'
,target NUMBER PATH '/USER_INFO/TARGET'
,state NUMBER PATH '/USER_INFO/STATE'
,task NUMBER PATH '/USER_INFO/TASK'
) y
COUNTRY POINT USER_ID TARGET STATE TASK
1 1800 1 28 6 12
1 1800 5 19 1 90
2 2400 3 14 7 5And then you can extract and insert whatever parts you want into whatever tables as part of the procedure.
Maybe you are looking for
-
How do I connect my new iMac to Apple TV
I recently bought a new iMac and I want to connect it to my old Apple TV from 2008. How does iTunes see the Apple TV?
-
How to custom table field to be sortable at core form
Hi, Can anyone provide the hint for the captioned topic. Example, R11i PO autocreate document form, column 'Requestor' is not sortable, how to custom it to be sortable? Thanks in advance. Rgds, CY
-
Error occured while reading from the device
I need help!!! whenever i try to update my iphone to the new 1.1.1 version, i get an error message saying "error occured while reading from the device" the same message comes up when i try to restore it. i havent mod'd my phone in any way. does anyon
-
I have a two week old MBP that I migrated all files from my previous PB G4. I use a wireless network at home and plug into a routed DSL ethernet network at work. The new MBP worked perfectly at my office (as did my PB G4 for years) until two days ago
-
Change name of airpoet express network
How to change name of wifi network?