Need SQl Query tune
Hi,
This is a part of the procedure which is veryyy slow.. Need some suggestions for the below Query to improve performance. The explain plan and all will be correct in PRODUCTION DB.. In that system, I cant have the explain plan to be copied here. So need suggestions by the Query.
Here PB,PBD and PBD1 are very huge tables..
I am unable to paste the Query.. Please help me
Thanks in advance..
My car is broken, but I cannot produce it for repairs.
Not sure of your expectations, but this isn't a way where volunteers have been provided any tiny piece of information to suggest any tuning advice.
Please read the linked thread HOW TO: Post a SQL statement tuning request - template posting and post with mentioned information.
Similar Messages
-
Need sql query to import from excel sheet
Hey , i need sql query to import from excel sheet.
i work in a company where i need to daily update the data from excel sheet.
if i get a shortcut method i ill be very thank full to you guys to reduce my work upto 10 %.any query which can inert from excel file?
Sort of. Certainly not anything as simple as what you seem to hope for. Check out this very good PHP class:
PHPExcel - Home -
Need Sql Query that Suppress the repeating rows.
Hi Sir,
I have below data set.
DeptID Sum(SAL) Avg(Sal)
10 1300 1300
10 2450 1300
10 5000 1300
20 800 800
20 1100 800
20 2975 800
20 3000 800
30 800 800
30 1100 800
30 2975 800
40 3000 800
40 4000 900
I Need SQL query that can remove the duplicate or suppress.Just like below data set.
Output:
DeptID Sum(SAL) Avg(Sal)
10 1300 1300
2450 1300
5000 1300
20 800 800
1100 800
2975 800
3000 800
800 800
30 1100 800
2975 800
40 3000 800
4000 900
Could you please help me on this..Your requiremnt is more of a reporting request which should not be handled in SQL. For example in SQL Plus you can use the BREAK command
SQL> break on deptno
SQL> select deptno, ename from emp order by deptno;
DEPTNO ENAME
10 KING
CLARK
20 JONES
SCOTT
SMITH
ADAMS
30 TURNER
MARTIN
WARD
ALLEN
BLAKE
11 rows selected.
SQL>
But if you still wish to do it in SQL you can use ROW_NUMBER analytic function and achieve it like this
select decode(rno, 1, deptno) deptno
, ename
from (
select row_number() over(partition by deptno order by ename) rno
, deptno
, ename
from emp -
Need sql query or pl/sql query urgent
Hi Experts,
The requirement is that
SELECT 'N' flag, sysdate init_date,
'' vendor_name,
DECODE (pa.address_type,
'P', 'Present Address',
'R', 'Permanent Address',
pa.address_type
) address_type,
pa.address_line1
|| ','
|| pa.address_line2
|| ','
|| pa.town_or_city
|| ','
|| meaning
|| ','
|| pa.POSTAL_CODE "Address",
TRUNC (TO_CHAR (pa.date_from, 'YYYY')) YEAR,
TO_CHAR (pa.date_from, 'MON') MONTH,''station
FROM per_addresses pa, fnd_lookup_values, per_all_people_f pf
WHERE (pf.employee_number = :1 or pf.APPLICANT_NUMBER = :2)
and pf.EFFECTIVE_END_DATE='31-DEC-4712'
AND pa.person_id = pf.person_id
AND pa.business_group_id = 42
--AND pa.date_to IS NULL
AND lookup_type = 'PER_US_COUNTRY_CODE'
AND lookup_code = pa.country
AND enabled_flag = 'Y'
AND (end_date_active IS NULL OR end_date_active > SYSDATE)
if i run the above query the output is coming like that
Present Address | Flat No. 1201, OC - 15, Orange County, Plot No. GH - 4,Ahinsa Khand 1st, Indrapuram,Ghaziabad,India,201010| 2,010| JUL
Permanent Address | Q.No. 354, Sector - 3 / B,,Bokaro Steel City,India,827003 |2,010 |JUL
Present Address | 4, Sitara,Chandra Reddy layout, S.T. Bed,Bangalore,India,0| 2,006| JAN
Present Address | 101,,Ushma Urja Apartments,Noida,India,201301 | 2,006 | JUL
Permanent Address | F-19, Maccon Colony, Opp. DAV Shyamali School,,Ranchi,India,834002 | 2,009 | FEB
Present Address | Flat no. 604, B - 1, Krishna Apra Gardens,Vaibhav Khand, Plot - 7,Ghaziabad,India,201010 | 2,009 FEB
But the requirement is the output should come like that
Permanent Address |Q.No. 354, Sector - 3 / B,,Bokaro Steel City,India,827003| 2,010 |JUL
Permanent Address 1| F-19, Maccon Colony, Opp. DAV Shyamali School,,Ranchi,India,834002| 2,009 | FEB
Present Address | Flat No. 1201, OC - 15, Orange County, Plot No. GH - 4,Ahinsa Khand 1st, Indrapuram,Ghaziabad,India,201010| 2,010 | JUL
Present Address 1 | Flat no. 604, B - 1, Krishna Apra Gardens,Vaibhav Khand, Plot - 7,Ghaziabad,India,201010| 2,009 | FEB
Present Address 2 | 101,,Ushma Urja Apartments,Noida,India,201301| 2,006| JUL
Present Address 3 | 4, Sitara,Chandra Reddy layout, S.T. Bed,Bangalore,India,0 | 2,006| JAN
Please provide logice how i need to write a sql query or procedure or function or package
Thanks & Regards
VenuYou can use analytics here :
SELECT
flag,
init_date,
vendor_name,
address_type ||' ' ||rn AS address_type,
Address,
YEAR,
MONTH,
station
FROM
SELECT
'N' flag,
sysdate init_date,
'' vendor_name,
DECODE (pa.address_type, 'P', 'Present Address', 'R','Permanent Address', pa.address_type ) address_type,
row_number() over(partition BY pa.address_type order by 1) AS rn,
pa.address_line1
|| ','
|| pa.address_line2
|| ','
|| pa.town_or_city
|| ','
|| meaning
|| ','
|| pa.POSTAL_CODE "Address",
TRUNC (TO_CHAR (pa.date_from, 'YYYY')) YEAR,
TO_CHAR (pa.date_from, 'MON') MONTH,
'' station
FROM
per_addresses pa,
fnd_lookup_values,
per_all_people_f pf
WHERE
pf.employee_number = :1
OR pf.APPLICANT_NUMBER = :2
AND pf.EFFECTIVE_END_DATE='31-DEC-4712'
AND pa.person_id = pf.person_id
AND pa.business_group_id = 42
--AND pa.date_to IS NULL
AND lookup_type = 'PER_US_COUNTRY_CODE'
AND lookup_code = pa.country
AND enabled_flag = 'Y'
AND
end_date_active IS NULL
OR end_date_active > SYSDATE
); -
HI
I want a sql query i.e., all employees list which are having lessthan maximum salary of manager in same departmnet;
my table is like this
employees
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)
if need the department table
departments:
DEPARTMENT_ID
NOT NULL NUMBER(4)
DEPARTMENT_NAME
NOT NULL VARCHAR2(30)
MANAGER_ID
NUMBER(6)
LOCATION_ID
NUMBER(4)Try this:
select
employees.last_name || ', ' || employees.first_name “Employee”,
employees.salary “Emp Salary”,
sub.salary “Mgr Salary”,
employees.department_id “Department”
from
employees,
( select
mgr.department_id dept,
max(mgr.salary) salary
from
employees,
employees mgr
where
employees.mgr = mgr.employee_id
group by
mgr.department_id) sub
where
employees.department_id = sub.dept
and employees.salary < sub.salary
Jeff -
Need sql query to remove duplicates using UNION ALL clause
Hi,
I have a sql query which has UNION clause.But the UNION clause is causing some performance issues.
To overcome that I have used UNION ALL to improve performance but its returning duplicates.
Kindly anyone send a sample SQL query where my primary objective is used to use UNION ALL clause and to consider unique rows (elimating duplicate
ones)
Any help will be needful for me
Thanks and Regardswhy not UNION? :(
another way also use MINUS
SQL>
SQL> with t as
2 (
3 select 1 if from dual union all
4 select 2 if from dual union all
5 select 1 if from dual union all
6 select 3 if from dual union all
7 select 3 if from dual
8 )
9 ,t2 as
10 (
11 select 1 if from dual union all
12 select 2 if from dual union all
13 select 3 if from dual union all
14 select 4 if from dual union all
15 select 5 if from dual
16 )
17 (select if from t
18 union all
19 select if from t2)
20 /
IF
1
2
1
3
3
1
2
3
4
5
10 rows selected
SQL> so
SQL>
SQL> with t as
2 (
3 select 1 if from dual union all
4 select 2 if from dual union all
5 select 1 if from dual union all
6 select 3 if from dual union all
7 select 3 if from dual
8 )
9 ,t2 as
10 (
11 select 1 if from dual union all
12 select 2 if from dual union all
13 select 3 if from dual union all
14 select 4 if from dual union all
15 select 5 if from dual
16 )
17 (select if from t
18 union all
19 select if from t2)
20 minus
21 select -99 from dual
22 /
IF
1
2
3
4
5
SQL> -
Need sql query to find out Joins attached with folders in Discoverer
Hi,
Can anyone let me know the sql query which can be used to identify the joins which are attached to the folders.
Actually we have to identify all the joins conditions from folders those are migrated from one instance to others.
Thanks
abhishekI recommend that you implement the admin EUL supplied by oracle, you can get there a lot of repository information (metalink note: 556932.1).
Try to use this (maybe you will need some pkg's):
SELECT
DECODE(KEYS.FK_MANDATORY,
1,
'Always exist in master folder',
'Might not exist in master folder') "Detail Item values",
EUL10G_US.EUL5_GET_JOIN(EXP.EXP_ID, 'N') "Join Master --> Detail",
KEYS.KEY_DESCRIPTION JOIN_DESCRIPTION,
KEYS.KEY_DEVELOPER_KEY JOIN_IDENTIFIER,
KEYS.KEY_NAME JOIN_NAME,
DECODE(SUBSTR(KEYS.KEY_NAME, 1, 19),
'AUTO_GENERATED_NAME',
'Yes',
'No') "AutoGen",
DECODE(DECODE(SUBSTR(KEYS.KEY_NAME, 1, 19),
'AUTO_GENERATED_NAME',
'Yes',
'No') ,
'Yes',
EUL10G_US.EUL5_GET_JOIN(EXP.EXP_ID),
KEYS.KEY_NAME) "Actual Join Name",
KEYS.KEY_UPDATED_DATE JOIN_LAST_UPDATE,
DECODE(KEYS.FK_ONE_TO_ONE, 1, 'One to one join', NULL) "One to One join",
DECODE(KEYS.FK_MSTR_NO_DETAIL,
1,
'Outer join on detail' || CHR(10),
NULL) "Outer Join on Detail",
DECODE(KEYS.FK_DTL_NO_MASTER,
1,
'Outer join on master' || CHR(10),
NULL) "Outer Join on Master",
DECODE(KEYS.FK_MSTR_NO_DETAIL,
1,
'Outer join on detail' || CHR(10),
NULL) || DECODE(KEYS.FK_DTL_NO_MASTER,
1,
'Outer join on master' || CHR(10),
NULL) ||
DECODE(KEYS.FK_ONE_TO_ONE, 1, 'One to one join', NULL) "Optional Join Configurations",
OBJ.OBJ_NAME "MASTER_FOLDER",
OBJ_DETAIL.OBJ_NAME "DETAIL_FOLDER"
FROM EUL10G_US.EUL5_OBJS OBJ,
EUL10G_US.EUL5_EXPRESSIONS EXP,
EUL10G_US.EUL5_KEY_CONS KEYS,
EUL10G_US.EUL5_OBJS OBJ_DETAIL
WHERE ((KEYS.KEY_ID = EXP.JP_KEY_ID) AND
(OBJ.OBJ_ID = KEYS.FK_OBJ_ID_REMOTE) AND
(OBJ_DETAIL.OBJ_ID = keys.KEY_OBJ_ID)); -
Need sql query to find out Joins attached with folders
Hi,
Can anyone let me know the sql query which can be used to identify the joins which are attached to the folders.
We dont want to see those from front end(disc admin).
Thanks
abhishekabhishek - This is the Application Express forum. I have no idea what you are asking but it may need to be directed to a different forum.
Scott -
Need sql query to find ten records in sequential manner
Plz help me
I need to have ten records on my page. at the bottom of the page, i want to dispaly the number of pages that have records , just as a google page shows at the bottom. if the moves user moves to the next page , the next ten records must be displayed. suppose the user selects and clicks 5th page then the records on that page are displayed.How can i write the sql query corresponding to this specificationi don't want all records to be fetched at the same time and put on the server, rather whenever the page is opened , the corresponding records are fetched and displayedHi
Maybe you should use a CachedRowSet.
Look this:
http://developer.java.sun.com/developer/technicalArticles/javaserverpages/cachedrowset/
This page has a example that will help you. -
Hi All,
i have input like
'JEFFRJON-Sales Manager-JEFFRJON'
'TBH01-JEFFRJON-Apps Agile Rep-JEFFRJON'
Need output only
Sales Manager
Apps Agile Rep
Please give me the sql query for this....anbarasan wrote:
Hi All,
i have input like
'JEFFRJON-Sales Manager-JEFFRJON'
'TBH01-JEFFRJON-Apps Agile Rep-JEFFRJON'
Need output only
Sales Manager
Apps Agile Rep
Please give me the sql query for this....You should really provide more info - like database version - so that people don't have to make assumptions when they try to help you. Based on limited requirements;
with t as (
select 'JEFFRJON-Sales Manager-JEFFRJON' str from dual union all
select 'TBH01-JEFFRJON-Apps Agile Rep-JEFFRJON' from dual)
select regexp_replace(str, '(.*JEFFRJON-)(.*)(-JEFFRJON.*)','\2') c
from t;
C
Sales Manager
Apps Agile Rep -
Need sql query for like operation.
Hi All,
i have table like name column and contain the data like
ibm 100
ibm 200
ibm 300
a2b
a
b
c
like this ....
but sql query need search using like or any regular expression---
select * from table where name like (ibm 200 and ibm 300).
and i don't want use like this select * from table where name like' ibm 200' or name like 'ibm 300').
can you please any body help to correct the above query...
Edited by: anbarasan on Oct 16, 2011 10:02 PMWITH t AS
(SELECT 'ibm 100' NAME
FROM DUAL
UNION ALL
SELECT 'ibm 200' NAME
FROM DUAL
UNION ALL
SELECT 'ibm 300' NAME
FROM DUAL
UNION ALL
SELECT 'a2b' NAME
FROM DUAL)
SELECT *from t where REGEXP_LIKE (name, 'ibm')
and REGEXP_LIKE (name, '100|200') -
Need SQl Query for Revenue Code and Revenue Amount in Receivables
Hi,
I need a SQL Query to develop data set for the following columns:
Revenue Code,Revenue Code Description,Invoice Amount,Revenue Amount,Original Invoice Number,Original Invoice Date.
Can i get from ra_cust_trx_line_gl_dist_all and ra_customer_trx_all and ra_customer_trx_lines_all by joining them.But for the columns whcih to take
i am in dilemma.
Kindly any help will be needful for meHi,
I need a SQL Query to develop data set for the following columns:
Revenue Code,Revenue Code Description,Invoice Amount,Revenue Amount,Original Invoice Number,Original Invoice Date.
Can i get from ra_cust_trx_line_gl_dist_all and ra_customer_trx_all and ra_customer_trx_lines_all by joining them.But for the columns whcih to take
i am in dilemma.
Kindly any help will be needful for me -
Hi All,
Could you please help me out the below SQL query tuning .
Temp table is having 1 Million records
Master table is having 60 Million records
Query :
SELECT B.*,U.ID, SD, LE, LAE
FROM client.Temp B, client.Master
U WHERE U.policyno = B.policyno
AND B.UPFLAG = 0
1. Indexes are created on both email columns and Upflag for both tables.
2. Gathered DBMS Stats for MASTER Table
Data is loading 100k/hour on production .When your query takes too long ...
When your query takes too long ...
HOW TO: Post a SQL statement tuning request - template posting
HOW TO: Post a SQL statement tuning request - template posting -
Need SQL query for PO that do NOT have 3-way match.
The question is -- have any PO"s been generated with other then 3-way match selected - which means they overrode the set-ups in purchasing , to see if there are an PO that do NOT have 3-way match.
Thanks
Mohan.1)Generally when ever we will do Supplier setup we will select in the Receiving tab Match approval level we will select either 3-way ,2-way,4-way or we will keep that as blank.
for that we do not have any direct column in the back end ,so we will use the following conditions.
'2WAY' inspection_required_flag = 'N'
receipt_required_flag = 'N'
'3WAY' inspection_required_flag = 'N'
receipt_required_flag = 'Y'
'4WAY' inspection_required_flag = 'Y'
receipt_required_flag = 'Y'
2)When ever we will create a PO in the shipments level what ever the Match approval level,
we defined in the supplier will automatically reflects in the shipments-More tab.
3)Here i wants to know all the PO's whihc are having Match approval level differences between supplier definiton and PO's match approval level.
(i.e If i will select a supplier for a PO , automatically we will get one Match approvallevel from supplier setup .if i will change that match approval level manually in the PO shipments -More tab i wants to know all that PO by using a SQL query.
4)But for some PO's i am getting receipt_required_flag and inspection_required_flag as null.But in the Supplier setup it may be one of the Matching approval.
Thanks
Mohan. -
Need SQL query to get the result.
Region
Month
Trx Type
Resolution Summary
AMERICAS
May-13
Adjustments
Correct
EMEA
May-13
Adjustments
Incorrect
AMERICAS
May-13
Credit Memo
Incorrect
EMEA
May-13
Invoice
Correct
AMERICAS
May-13
Credit Memo
Correct
OFD
May-13
Adjustments
Correct
AMERICAS
May-13
Invoice
Incorrect
LAD
May-13
Adjustments
Correct
LAD
May-13
Adjustments
Correct
OFD
May-13
Adjustments
Correct
Above is my Table and find below the required result.Similarly for other regions as well. Can anyone help me with the SQL Query?
Region
Resolution Summary
Adjustment
Credit Memo
Invoice
Grand Total
AMERICAS
Correct
1
1
2
Incorrect
0
1
1
2Like this?
SQL> select * from transaction_audit;
REGION MTH TRX_TYPE RESOLUTIO
AMERICAS may-13 ADJUSTMENTS CORRECT
EMEA may-13 ADJUSTMENTS INCORRECT
AMERICAS may-13 CREDIT MEMO INCORRECT
EMEA may-13 INVOICE CORRECT
AMERICAS may-13 CREDIT MEMO CORRECT
OFD may-13 ADJUSTMENTS CORRECT
AMERICAS may-13 INVOICE INCORRECT
LAD may-13 ADJUSTMENTS CORRECT
LAD may-13 ADJUSTMENTS CORRECT
OFD may-13 ADJUSTMENTS CORRECT
10 rows selected.
SQL> select region
2 , resolution_summary
3 , count(decode(trx_type, 'ADJUSTMENTS', trx_type)) adjustments
4 , count(decode(trx_type, 'CREDIT MEMO', trx_type)) credit_memo
5 , count(decode(trx_type, 'INVOICE' , trx_type)) invoice
6 from transaction_audit
7 group
8 by region
9 , resolution_summary
10 order
11 by region
12 , resolution_summary
13 /
REGION RESOLUTIO ADJUSTMENTS CREDIT_MEMO INVOICE
AMERICAS CORRECT 1 1 0
AMERICAS INCORRECT 0 1 1
EMEA CORRECT 0 0 1
EMEA INCORRECT 1 0 0
LAD CORRECT 2 0 0
OFD CORRECT 2 0 0
6 rows selected.
SQL>
Maybe you are looking for
-
Iphone is only recognized in restore mode
What would make iTunes for windows 7 recognize iPhone in recovery mode, but not to proceeded with restore, stopping on the "snow cane". Completely not recognize restored iPhone, not even by windows auto play. iTunes diagnostics runs with everything
-
I am connected to wifi, but can't open webpages or collect mail
I am connected to wifi, but can't open webpages or collect mail. I have tried to reconnect; to forget the network, all those things that should hepl. My phone and my computer recognize the network, the ipad doesn't. I mean I am connected and have a
-
Question Hi I am doing a photo course unable to paste from microsoft word, publisher to the course how do I do this
-
How one can print a page to pocket printer from handset of nokia 40 series/
how one can print a page to pocket printer from handset of nokia 40 series/60series/80 series if u have any information regarding these two question the pls send me the link
-
I went through all of the settings, turned it off, even reset it, but cannot get my iPhone 4s to ring or for the speaker to work when in the phone.