Need a Suggestion tune the SQL query
HelloThere is a view that is created that takes 17 seconds to run the query, when I split the query and run each query prend.15 seconds to run. Below the query I need to improve the performance of the code if you need your suggestion please order to tweek so this time take for execution to become less
SELECT "Parature'"Source. "
NULL 'retailer ',.
reseller_name "reseller."
NULL city "reseller."
NULL state "reseller."
A.Country "dealer Country."
DECODE (a.state, "ACPA", "ACPA", 'EMEA', 'EMEA', NULL, 'Unknown', 'US') "Dealer Theater",
NULL "Customer Name,"
NO city 'customer ',.
'Client state', NULL
NULL 'country of the customer. "
NULL "customer Theater."
NULL "sales book Date."
NULL "Ship Date."
c.sales_order_number 'Sales Order Number',
C.Po_Number "Number"
controller_model_number_1 "product name."
TRIM (UPPER (serial_number_1)) 'product serial number.
c.contract_id "Contract ID",
product_name 'name of support. "
To_date (c.contract_purchase_date) "Start Date"
To_date (c.contract_expiration_date) 'Expiry Date',
NULL "header Status."
NULL "status of line."
NULL 'line Type. "
NULL "reason for termination of employment."
NULL 'location_id. "
NULL 'Product_id '.
Of edb_assets c,.
edb_accounts one
WHERE controller_model_number_1! = 'NULL '.
AND Serial_Number_1! = 'NULL '.
AND C.Amid = A.Amid (+)
UNION
SELECT "Parature'"Source. "
NULL 'retailer ',.
reseller_name "reseller."
NULL city "reseller."
NULL state "reseller."
A.Country "dealer Country."
DECODE (a.state, "ACPA", "ACPA", 'EMEA', 'EMEA', NULL, 'Unknown', 'US') "Dealer Theater",
NULL "Customer Name,"
NO city 'customer ',.
'Client state', NULL
NULL 'country of the customer. "
NULL "customer Theater."
NULL "sales book Date."
NULL "Ship Date."
c.sales_order_number 'Sales Order Number',
C.Po_Number "Number"
controller_model_number_2 "product name."
TRIM (UPPER (serial_number_2)) 'product serial number.
c.contract_id "Contract ID",
product_name 'name of support. "
To_date (c.contract_purchase_date) "Start Date"
To_date (c.contract_expiration_date) 'Expiry Date',
NULL "header Status."
NULL "status of line."
NULL 'line Type. "
NULL "reason for termination of employment."
NULL 'location_id. "
NULL 'Product_id '.
Of edb_assets c,.
edb_accounts one
WHERE controller_model_number_2! = 'NULL '.
AND serial_number_2! = 'NULL '.
AND C.Amid = A.Amid (+)
UNION
SELECT "Parature'"Source. "
NULL 'retailer ',.
reseller_name "reseller."
NULL city "reseller."
NULL state "reseller."
A.Country "dealer Country."
DECODE (a.state, "ACPA", "ACPA", 'EMEA', 'EMEA', NULL, 'Unknown', 'US') "Dealer Theater",
NULL "Customer Name,"
NO city 'customer ',.
'Client state', NULL
NULL 'country of the customer. "
NULL "customer Theater."
NULL "sales book Date."
NULL "Ship Date."
c.sales_order_number 'Sales Order Number',
C.Po_Number "Number"
controller_model_number_3 "product name."
TRIM (UPPER (serial_number_3)) 'product serial number.
c.contract_id "Contract ID",
product_name 'name of support. "
To_date (c.contract_purchase_date) "Start Date"
To_date (c.contract_expiration_date) 'Expiry Date',
NULL "header Status."
NULL "status of line."
NULL 'line Type. "
NULL "reason for termination of employment."
NULL 'location_id. "
NULL 'Product_id '.
Of edb_assets c,.
edb_accounts one
WHERE controller_model_number_3! = 'NULL '.
AND serial_number_3! = 'NULL '.
AND C.Amid = A.Amid (+)
UNION
SELECT "Parature'"Source. "
NULL 'retailer ',.
reseller_name "reseller."
NULL city "reseller."
NULL state "reseller."
A.Country "dealer Country."
DECODE (a.state, "ACPA", "ACPA", 'EMEA', 'EMEA', NULL, 'Unknown', 'US') "Dealer Theater",
NULL "Customer Name,"
NO city 'customer ',.
'Client state', NULL
NULL 'country of the customer. "
NULL "customer Theater."
NULL "sales book Date."
NULL "Ship Date."
c.sales_order_number 'Sales Order Number',
C.Po_Number "Number"
controller_model_number_4 "product name."
TRIM (UPPER (serial_number_4)) 'product serial number.
c.contract_id "Contract ID",
product_name 'name of support. "
To_date (c.contract_purchase_date) "Start Date"
To_date (c.contract_expiration_date) 'Expiry Date',
NULL "header Status."
NULL "status of line."
NULL 'line Type. "
NULL "reason for termination of employment."
NULL 'location_id. "
NULL 'Product_id '.
Of edb_assets c,.
edb_accounts one
WHERE controller_model_number_4! = 'NULL '.
AND serial_number_4! = 'NULL '.
AND C.Amid = A.Amid (+)
UNION
SELECT "Parature'"Source. "
NULL 'retailer ',.
reseller_name "reseller."
NULL city "reseller."
NULL state "reseller."
A.Country "dealer Country."
DECODE (a.state, "ACPA", "ACPA", 'EMEA', 'EMEA', NULL, 'Unknown', 'US') "Dealer Theater",
NULL "Customer Name,"
NO city 'customer ',.
'Client state', NULL
NULL 'country of the customer. "
NULL "customer Theater."
NULL "sales book Date."
NULL "Ship Date."
c.sales_order_number 'Sales Order Number',
C.Po_Number "Number"
controller_model_number_5 "product name."
TRIM (UPPER (serial_number_5)) 'product serial number.
c.contract_id "Contract ID",
product_name 'name of support. "
To_date (c.contract_purchase_date) "Start Date"
To_date (c.contract_expiration_date) 'Expiry Date',
NULL "header Status."
NULL "status of line."
NULL 'line Type. "
NULL "reason for termination of employment."
NULL 'location_id. "
NULL 'Product_id '.
Of edb_assets c,.
edb_accounts one
WHERE controller_model_number_5! = 'NULL '.
AND serial_number_5! = 'NULL '.
AND C.Amid = A.Amid (+)
UNION
SELECT "Source", "ERP"
Imv.Bill_To 'retailer ',.
Imv.Ship_To "dealer."
Ship_To_City "Dealer City."
Ship_To_State "State dealer."
Edb2_Global.Country_Name_Theater (Imv.Ship_To_Country, 'COUNTRY') 'dealer country. "
Edb2_Global.Country_Name_Theater (Imv.Ship_To_Country, 'THÉÂTRE') 'dealer Theater. "
Cl.Company_Name "name of the customer."
Cl.City "customer's city."
Cl.State "State of the customer."
Edb2_Global.Country_Name_Theater (cl.) Country, 'COUNTRY') 'country of the customer. "
Edb2_Global.Country_Name_Theater (cl.) Country, 'THEATER') "customer Theater."
Imv.So_Booked_Date "Date from the sale of book."
Imv.Ship_Date "Delivery Date"
Imv.Order_Number "client order number."
Imv.Cust_Po_Number "Number"
Cp.Item_Name "product name."
Cp.Product_Serial_Number "serial number of product."
To_char (Imv.contract_number) "Contract ID"
Imv.Service_Description "name of support."
Imv.Service_Start_Date "Start Date"
Imv.Service_End_Date "expiration Date."
Imv.Header_Status "header Status."
Imv.Line_Status "status of line."
Imv.Line_Type 'line Type. "
Imv.Termination_Reason "reason for termination of employment."
Cl.Location_Id 'location_id. "
CP.ID "Product_id".
Of ib_support_contracts_mv imv.
customer_products cp,
customer_locations cl
WHERE superior (Trim (Imv.Serial_Number)) = Upper (Trim (Cp.Product_Serial_Number (+)))
AND Cp.Location_Id = Cl.Location_Id (+)
/
There is a Union for each request, please suggest how tweek
Thank you
Sudhir
A quick look indicates that first 5 select queries are that even accepting the 2 conditions
WHERE controller_model_number_1! = 'NULL '.
AND Serial_Number_1! = 'NULL '.
Use SEPARATE and Clause OR reduce these 5 queries in one like that
SELECT DISTINCT
.....
......
FROM edb_assets c
,edb_accounts a
WHERE C.Amid = A.Amid(+)
AND (
( controller_model_number_1 != 'NULL'
AND Serial_Number_1 != 'NULL'
)
OR
( controller_model_number_2 != 'NULL'
AND Serial_Number_2 != 'NULL'
)
OR
( controller_model_number_3 != 'NULL'
AND Serial_Number_3 != 'NULL'
)
OR
( controller_model_number_4 != 'NULL'
AND Serial_Number_4 != 'NULL'
)
OR
( controller_model_number_5 != 'NULL'
AND Serial_Number_5 != 'NULL'
)
)
Concerning
Arun
Published by: Arun Kumar Gupta on May 9, 2012 12:10
Tags: Database
Similar Questions
-
Need help to write the SQL query
Hello
Please help me to write a query. My requirement is as below.
Hello
I have a table say XYZ in the following format.
product_id local min_order_quntity
========================================
1 en 10
1 ch 10
2 en 20
2 ch 20
3 en 30
3 ch 30
4 en 40
4 NC 10
Now I want to find the product_id where min_order_quantity is different for cn and locale
now I want the result of the following
product_id local min_order_quantity
=============================================
4 en 40
4 ch 10
This is different for local in and cn for product_id 4 min_order_quantity
min_order_quantity should be the same for both the locale(en,ch) for any product_id.
I want to find the product_id where min_order_quantity is different for ch and fr local
Thank you..Hello
This query should do the job
select * from xyz t1 where exists ( select 1 from xyz t2 where t2.product_id = t1.product_id and t2.locale != t1.locale and t2.min_order_quantity != t1.min_order_quantity );
See you soon
-
Need help to build the SQL query
Hi all
I struggle to create the select statement.
This is my expected outcome:
Insert into tmp (aa, bb, cc, dd)
values('CUST1','10100001',2,'10-Jan-2013');
Insert into tmp (aa, bb, cc, dd)
values('CUST1','10100002',4,'11-Jan-2013');
Insert into tmp (aa, bb, cc, dd)
values('CUST2','10200001',2,'19-Jan-2013');
Insert into tmp (aa, bb, cc, dd)
values('CUST2','10200002',6,'28-Jan-2013');
Insert into tmp (aa, bb, cc, dd)
values('CUST2','10200003',1,'28-Mar-2013');
My result is:
AA COUNT (1) MAX (DD) by cc dd AA AA
CUST1 2 10100002 4 11 January 2013
CUST2 3 10200003 1 28 MARCH 2013
Can someone help with the select statement?
Thank you and best regards,
Iwan
Just change it to the column:
SELECT
AA
COUNT (aa)
, MAX (bb) keep (last dense_rank command by JJ)
, MAX (cc) keep (last dense_rank command by JJ)
MAX (dd)
OF THE TMP
GROUP BY aa
ORDER BY aa
Note that by default sort order is ascending with the last NULL values.
If in case your line-date-max will contain null value in the bb or cc columns those will be returned.
Post edited by: Correction of chris227
Post edited by: chris227 added note
-
Hi all
Here is the sql query,
Select papf.employee_number,
-papf.full_name, ppa.effective_date, pp.payroll_name,
PET.element_name,
PIV. Name input_value,
prrv.result_value
-, ppa.payroll_action_id, ppa.time_period_id
Of
Apps.pay_payroll_actions App,
pay_assignment_actions AAP,
pay_payrolls_f pp,
pay_run_results prr,
prrv pay_run_result_values,
pay_input_values_f piv,
animal pay_element_types_f,
Apps.per_all_assignments_f ADP,
Apps.per_all_people_f women's wear
-where ppa.payroll_action_id =: payroll_action_id - give your payroll_action_id
where ppa.payroll_id =: payroll_id
and ppa.payroll_action_id =: payroll_action_id
- and paa.assignment_action_id =: assignment_action_id
and ppa.payroll_action_id = paa.payroll_action_id
and ppa.payroll_id = pp.payroll_id
and paa.assignment_action_id = prr.assignment_action_id
and prr.run_result_id = prrv.run_result_id
and prrv.input_value_id = piv.input_value_id
and piv.element_type_id = pet.element_type_id
and paaf.assignment_id = paa.assignment_id
and paaf.person_id = papf.person_id
and trunc (sysdate) between pp.effective_start_date and pp.effective_end_date
and trunc (sysdate) between pet.effective_start_date and pet.effective_end_date
and trunc (sysdate) between piv.effective_start_date and piv.effective_end_date
and trunc (sysdate) between paaf.effective_start_date and paaf.effective_end_date
and trunc (sysdate) between papf.effective_start_date and papf.effective_end_date
- and papf.employee_number = '1'
- and ppa.effective_date = July 22, 2014"
and pet.element_name in ('Local Mission allowance', "Compensation of Mission International")
order by 1.3
The result is:
Employee_number Element_Name Input_Value Result_value
1 compensation of Mission international day amount 1000
1 compensation of international Mission Distance days 4
1 value to pay compensation of 1200 International Mission
1 International Mission allowance Start Date 01/01/2014
1 compensation of Mission international day amount 800
1 compensation of international Mission Distance days 10
1 International Mission allowance pay value 2000
1 International Mission allowance Start Date 01/02/2014
1 compensation of Mission local day amount 500
1 compensation of local Mission Distance days 10
1 Mission allowance paid local value 1000
1 compensation of local Mission Start Date 01/11/2014
Desired output:
Employee_number Element_Name Day_Amount Distance_Days Pay_Value Start_Date
1 compensation of international Mission 1000, 1200 4 2014/01/01
1
International Mission allowance 800 10 2000 01/02/2014 1 Mission local compensation 500 10 1000 01/11/2014 Please suggest.
INSERT statement:
TOGETHER TO DEFINE
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'Day amount', '1000');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'Day amount', '1000');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'number of orders', '196');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'number of orders', '195');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', ' Distance days, 4 ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', ' Distance days, 1 ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
("1', 'International Mission allowance', 'employee Category", "scale of employment medical cities");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
("1', 'International Mission allowance', 'employee Category", "scale of employment medical cities");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'Class level', 'G3');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'Class level', 'G3');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'class of employment, ' ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'class of employment, ' ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'Country of Mission', ' 3003 - Kuwait ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'Country of Mission', ' 2004 - Canada ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', ' Mission days, 4' ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', ' Mission days, 3' ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'compensation of Mission international","End of Mission Date"' 2014/07/10 00:00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'compensation of Mission international","End of Mission Date"' 2014/07/19 00:00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'compensation of Mission international", 'Mission Start Date', ' 2014/07/07 00:00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'compensation of Mission international", 'Mission Start Date', ' 2014/07/17 00:00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'value of pay', '3000');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'value of pay', '4000');
00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'Local Mission allowance', 'number of orders', '45');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'Local Mission allowance', 'number of orders', "456789");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70 ', 'local Mission allowance', ' away days '0' ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70 ', 'local Mission allowance', ' Distance days, 1 ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70 ', 'local Mission allowance', 'Provided food', 'Y');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'compensation of local Mission","Accommodation provided", 'Y');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'compensation of local Mission","Accommodation provided", 'Y');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70 ', "local Mission allowance", "Mission City", "AL MEDINA");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70 ', "local Mission allowance", "Mission City", "RIYADH");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70 ', 'local Mission allowance', ' Mission days, 4' ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70 ', 'local Mission allowance', ' Mission days, 5' ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'Local Mission allowance', 'End of Mission Date' ' 2014/06/16 00:00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'Local Mission allowance', 'End of Mission Date' ' 2014-06-14 00:00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'Local Mission allowance', 'Mission Start Date', ' 2014/06/13 00:00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'Local Mission allowance', 'Mission Start Date', ' 2014/06/10 00:00:00 ');
Thank you very much in advance.
Kind regards
Afzal.
So then... something like this:
SELECT employee_number
element_name
MAX (decode (input_value, 'Day amount', result_value)) AS day_amount
MAX (decode (input_value, 'Days of Distance', result_value)) AS Distance_Days
, MAX (decode (input_value, 'Value of pay', result_value)) AS Pay_Value
MAX (decode (input_value, 'Start Date', result_value)) AS Start_Date
from (SELECT papf.employee_number
pet.element_name
piv.NAME input_value
prrv.result_value
prrv.run_result_id
OF apps.pay_payroll_actions App
pay_assignment_actions PAA
pay_payrolls_f pp
pay_run_results prr
pay_run_result_values prrv
pay_input_values_f piv
pay_element_types_f pet
apps.per_all_assignments_f ADP
apps.per_all_people_f women's wear
-where ppa.payroll_action_id =: payroll_action_id - give your payroll_action_id
WHERE ppa.payroll_id =: payroll_id
AND ppa.payroll_action_id =: payroll_action_id
- and paa.assignment_action_id =: assignment_action_id
AND ppa.payroll_action_id = paa.payroll_action_id
AND ppa.payroll_id = pp.payroll_id
AND paa.assignment_action_id = prr.assignment_action_id
AND prr.run_result_id = prrv.run_result_id
AND prrv.input_value_id = piv.input_value_id
AND piv.element_type_id = pet.element_type_id
AND paaf.assignment_id = paa.assignment_id
AND paaf.person_id = papf.person_id
AND trunc (sysdate) BETWEEN pp.effective_start_date AND pp.effective_end_date
AND trunc (sysdate) BETWEEN pet.effective_start_date AND pet.effective_end_date
AND trunc (sysdate) BETWEEN piv.effective_start_date AND piv.effective_end_date
AND trunc (sysdate) BETWEEN paaf.effective_start_date AND paaf.effective_end_date
AND trunc (sysdate) BETWEEN papf.effective_start_date AND papf.effective_end_date
AND pet.element_name IN ('local Mission allowance', 'International Mission'))
GROUP BY employee_number
element_name
run_result_id
;
You should get your desired result.
Roger
-
Hey guys,.
I'm using version 4.2.6 apex. The theme is 26.
IM also using Listener Oracle APEX.
I can print my classic report in PDF or CSV format.
But I need to export it as a .xls extension.
Report type: SQL (body of function from PL/SQL returning the SQL) query
I need is like this cause my 'where' clause type is dynamic.
Look at using this method: Tom's Blog: a non-standard export excel 2010 (.xlsx)
I do something similar for downloads to excel in my projects...
Thank you
Tony Miller
Software LuvMuffin
Ruckersville, WILL -
Clarification of the SQL query in 2 day + Guide APEX
I worked through the Oracle Database Express Edition 2 day + Application Express Developer's Guide, and try to decipher the SQL query in Chapter 4 (building your app).
The code is:
SELECT d.DEPARTMENT_ID,
d.DEPARTMENT_NAME,
(select count (*) from oehr_employees where department_id = d.department_id)
"Number of employees", he said.
substr (e.first_name, 1, 1) |'. ' || Select 'Name Manager',
c.COUNTRY_NAME 'place '.
OEHR_DEPARTMENTS d,
E OEHR_EMPLOYEES
OEHR_LOCATIONS l,
C OEHR_COUNTRIES
WHERE d.LOCATION_ID = l.LOCATION_ID
AND l.COUNTRY_ID = c.COUNTRY_ID
AND e.department_id = d.DEPARTMENT_ID
AND d.manager_id = e.employee_id
AND instr (superior (d.department_name), superior (nvl (:P2_REPORT_SEARCH,d.department_name))) > 0)
I don't know exactly what is happening in the last line. I think I understand what the different functions but I'm not clear on the use of the: P2_REPORT_SEARCH string.
What does this string? This code simply checking that d.department_name isn't NA?
I have SQL experience but am not very familiar with the Oracle PL/SQL implementation. Can someone please give me a brief breakdown that check is doing in the context of the overall query? The application seems to work even if the conditional statement is not included.
Thank you.
2899145 wrote:
Thanks for the reply. I apologize if the information I added was incomplete. The code came from the day 2 + Application Express (version 4.2) Developer Guide.
In the section 'your own Application of 4 Buuilding' https://docs.oracle.com/cd/E37097_01/doc.42/e35122/build_app.htm#TDPAX04000 , they describe the creation of a report
page that includes the "manager_id" and 'location_id '. The SQL query, I pasted above extracted from the data in other tables to substitute the real 'name of the Manager' and 'rent '.
for the corresponding ID values. It makes sense, and the part of the SQL query that explicitly doing this makes sense.
However, given that the document is a guide for the development of the APEX, I guess the command:
AND instr (upper (d.department_name), upper (nvl (:P2_REPORT_SEARCH,d.department_name))) > 0
done something valuable, and I do not recognize what is exactly the value.
From a practical point of view why would I need to include this conditional statement? Which only added to the application?
Looking at the guide in question, it is clear that the
AND instr(upper(d.department_name),upper(nvl(:P2_REPORT_SEARCH,d.department_name)))>0
the line is completely unnecessary in the context of this tutorial, and it can be removed. The search in the tutorial app page is implemented by using a report filter interactive rather than a P2_REPORT_SEARCH element, which does not seem to exist at all. (It's a quirk of the APEX that bind variable references to non-existent items are replaced with NULL silently rather than exceptions). I thought that perhaps it would be legacy code a version of the tutorial prior to the introduction of interactive reports at the APEX 3.1, but I can't find explicit instructions to create such an element of filter in the 3.0 tutorial. I guess it must have been automatically generated by the application wizard when you create a standard report page.
If you do not want to see the effect he would have (as described in the post above), leave it in the source report, add a text element of P2_REPORT_SEARCH, and a button "submit" on page 2 and experimenting to find different values of the element and clicking on the submit button...
-
Format the results of the SQL query, currently, show as below.
Select license_type, correspondents of license_info where license_type in ('TEM', 'TDM') order by license_type;
TDM 1445140800000000000
TDM 1420952400000000000
TDM 1444363200000000000
TDM 1445054400000000000
TDM 1428724800000000000
TEM 1421125200000000000
TEM 1423890000000000000
TEM 1449637200000000000
TEM 1444968000000000000
TEM 1428724800000000000I need formatting like below
Expected result:
TDM 1445140800000000000 TEM 1421125200000000000
TDM 1420952400000000000 TEM 1423890000000000000
TDM 1444363200000000000 TEM 1449637200000000000
TDM 1445054400000000000 TEM 1444968000000000000
TDM 1428724800000000000 TEM 1428724800000000000I have sample data only, Blue said the change in your main table request
Try:
Select max (f1),
Max (F2),
Max (F3),
Max (F4)
de)
Select decode (license_type, 'TDM' license_type) f1,
Decode (license_type, 'TDM', expiration_date) f2,
Decode (license_type, 'TEM' license_type) f3,
Decode (license_type, 'TEM', expiration_date) f4,
ROW_NUMBER() over (partition by order correspondents license_type) r
Of
)
R group
----
Ramin Hashimzade
-
What can be the SQL query for this requirement?
Hello
I have a table with the fields like this:
ID DESC PARENT
01 02 ABC
02 01 ABC1
03 01 ABC2
04 02 ABC4
In the table above column PARENT refers to the column ID, but actually in the SQL query, I want to have ID DESC and PARENTDESC (i.e., desc ID value corresponding)
Output real I need is
SELECT ID, DESC? from table where ID = someValue. Now, if I provided ID = 01 then output should be like this:
ID DESC PARDESC
ABC1 ABC 01
Can anyone help on what may be the required sql query?
Published by: bootstrap on April 29, 2011 06:15SELECT T1.ID, T1. DESC, T2. / / DESC
FROM TABLEA T1, T2 TABLEA
WHERE T1.ID = '01'
AND T2.ID = T1. PARENT; -
'||' Operator in the sql query
Hi all
We use the "|" operator in the sql query. Under the terms of the performance, it's beneficial or not?
Please suggest me.
Select * from EMP
where (ename | empno) in ('xxx' | 'yyyy')
Thanks in advance...Select * from emp where (ename||empno) in ('xxx'||'yyyy')
What is the reason using the ' |'?
Similar results could be achieved by article AND only
Select * from emp where ename = 'xxx' and empno = 'yyyy'
-
After migrating my APEX 4.1 application to a new environment, one classic report displays a "cannot parse the SQL query: ORA-00942: table or view does not exist" error when the page is displayed. Change the region to report SQL source to somehow (e.g., remove spaces, changing the order of the variables in the WHERE clause) immediately solves the problem, but by returning to the source of the region causes the report error again (the source region valid code without error, however).
Throw the error message:
Select v.id,
v.Col1
of view_vw v
where (: P1_FILTER is null or)
v.col2 = :P1_FILTER)
Do not throw error:
Select v.id,
v.Col1
of view_vw v
where (:P1_FILTER is null or)
v.col2 = :P1_FILTER)
Changing the order of column in the report has the same effect; i.e. He arranges, but return back to the original column order causes the error to display.
It's as if a cached result for the correct select statement used by the report is displayed. However, the application does not use the caching of page/region. Any ideas of what could be the cause?
He solved. Ultimately, all that was necessary was to clear the DB cache using:
alter system flush shared_pool;
-
Table error ' can not analyze the SQL query!
Hi all
I created a view on my database called VIEW_MEMBER_PARTIC_PROJECTS
If I run a query showing the results of the view:
SELECT * FROM VIEW_MEMBER_PARTIC_PROJECTS
I get the following data
Projects Participants 1 31 S 2 41 3 19 4 3 5 3 6 1 7 2 Now, I wanted to represent this diagram in the APEX so I created a graphic region and entered the Source query generator and the manufacturer produces the following code
Select null, label projects, value1 Participant link
of "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS ".
With this code, I get an error:
Cannot parse the SQL query!
Select the link null, label projects, value1 "SCHEMANAME Participant." "" VIEW_MEMBER_PARTIC_PROJECTS ".
Some queries can be run when you run your application, if your query is syntactically correct, you can save your query without validation (see options below the source of the query).
The code looks OK, but I do not see to save options as the error code is mentioned.
No one knows how to fix this?
Thank you
JaReg wrote:
I finally found the problem.
I looked at the code for the view and changed the start of:
CREATE OR REPLACE FORCE EDITIONABLE VIEW "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS "("Participant","Projects")
AS
TO
CREATE OR REPLACE VIEW "SCHEMANAME." "" VIEW_REPEAT_PARATIC ".
AS
And that seemed to fix it. I'm not entirely sure why though.
The view was created using the quoted identifiers for column names. This makes them sensitive and means that they must always be referenced using double quotes. In the absence of quotation marks, Oracle is not case insensitive and automatically converts all uppercase identifiers. The application of graph:
Select the link null, label projects, value1 "SCHEMANAME Participant." "" VIEW_MEMBER_PARTIC_PROJECTS ".
has therefore been interpreted by Oracle:
SELECT THE LINK NULL, LABEL, VALUE1 "SCHEMANAME PARTICIPANT PROJECTS." "" VIEW_MEMBER_PARTIC_PROJECTS ".
and PROJECTS and PARTICIPANT columns were not recognized because the columns defined for the view have been 'Participant' and 'projects '. The graphic request should have been:
Select the link null, the label of "Projects", "Participant" value1 "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS ".
As you have now discovered, quoted identifiers are a source of nothing but obscure bugs and should never be used for database objects. He also pointed out the reason why you should always use a standardized, form tiny, coding style as it is faster to type, easy to read and less prone to errors.
-
How to select only the part by using the sql query
Hello
I have the task to retrieve only the integral of the input text by using the sql query.
The entry is as follows
Entry for the price setting
$12.5 (FYI without space)
$ 12.5 (FYI single space)
$ 12.5 (double space FYI)
$12.5 (FYI multiple space)
$12.5 (FYI multiple space)
Output expected of 12.5
The price is the type varchar2 column in the store_price table.
Please let me know how to achieve this.
Thanks in advance.
If this is always the case that you get a $ followed by a number of places, you can use something like:
Select to_number (ltrim ('$ 12.5',' $')) DOUBLE
or
SELECT ltrim ('$ 12.5',' $') OF double
but take care of your nls_numeric_character settings if they are defined so that, for example, a comma is the decimal separator, you will have a problem.
HTH
-
Hi all..
It's SOA 11.1.1.7... I created the schema and storage via RCU but when I try to configure JDBS schema components... his throw this error:
CFGFWK-60850: the Test failed!
CFGFWK-60853: A connection to the database, but no lines have been returned to the examination of the SQL query.
I created 3 users of UCR and who were all successful, because I have no error... of these three alone is managed in the configuration tree SOA...
No idea why like that...
Thank you
Aerts
This that I solved it by installing EMP 11.1.2.2 with UCR and SOA 11.1.1.6...
-
Use the DECODE and RIGHTEOUS in the sql query
Friends...
Could someone help with DECODE and sql RIGHT or similar function?
I'm doing below in the SQL query
- DECODE any process with s.process = 1234 to replace with JAVA
- RIGHT: Removes all characters after ' @' sign
SQL query:
SELECT s.osuser, s.machine, DECODE(s.process, '1234', 'JAVA', right(s.process,charindex('@',s.process)-1)) s.process FROM v$session;
for example
EXAMPLES of data
User, machine, process
John, mac1, 1234
Mike, mac2, 567@mac2
Julie, mac3, 890
The result of the SAMPLE:
User, machine, process
John, mac1, JAVA
Mike, mac2, 567
Julie, mac3, 890
Thanks in advance
Thanks guys... I am overwhelmed with all these answers and support on this forum, I received...
I have combined Solomon and Frank response to achieve accurate result...
with the answers of Solomon he displayed empty process when there is ' @' sign
Frank's response showed it process with sign @ the end... so I added '-1' in the end.»
SELECT s.osuser,
s.machine,
DECODE)
s.Process,
"1234", "JAVA",
substr)
s.Process,
1,
InStr)
s.Process | '@',
) - 1
)
) process
V $ session s
/
-
Hello
Here's my data in the table for itm_id = 1000
ITM_ID ADD_ATR DEL_ATR 1000 a: b:c:d 1000 d 1000 d 1000 e:f:g 1000 e:f:g My required return is (a: b:c:d) d = a: b: c + d = a: = a +(e:f:g) b:c:d: b:c:d:e:f:g-(e:f:g) = a: b: c; d
Output ITM_ID
1000A: b:c:d
can we get the output using the sql query above?
I had tried with union but could not able to get the required result.
Please let me know if there is no possible solution
Thank you
David
I have the impression that you are looking to treat each character in 'RTA' as an individual item and then add or delete depending on whether they are an ADD_ATR or DEL_ATR.
So something like...
SQL > ed
A written file afiedt.buf1 with t as (select 1000 as itm_id, ' a: b/c: some like add_atr, null as del_atr of all the double union)
2 select 1000, null, would be "union double all the"
3 select 1000, 'd', null of union double all the
4 select 1000, 'e:f:g', null of union double all the
5 select 1000, null, "e:f:g" of all the double union
6 select 1234, null, "x: y: z" of all the double union
7 select 1234, 'u: v: w', null of union double all the
8 select 1234, null, 'u' of all the double union
9 select 1234, "x: y", null of union double all the
10. Select 1234, "x: z", null of union double all the
11. Select 1234, 'p', the double null
12 )
13-
14. end of test data
15-
16. Select itm_id
17, cast (listagg(atr,':') within the Group (order by atr) as varchar2 (40)) output
18 of)
19 select itm_id
20, atr
21, sum (add_del)
22 of)
23 select itm_id
24, coalesce(add_atr,del_atr) as full_atr
25, decode (add_atr, null,-1, 1) as add_del
26, regexp_substr (coalesce(add_atr,del_atr),'[^:] +', 1, level) RTA
27, flat surface that l
28 t
29 to connect by level<= (length(coalesce(add_atr,del_atr)="">=>
30 and itm_id = prior itm_id
31 and coalesce(add_atr,del_atr) = prior coalesce(add_atr,del_atr)
sys_guid() 32 and prior is not null
33 )
34 group by itm_id, atr
35 having sum (add_del) > 0
36 )
37 * group by itm_id
SQL > /.ITM_ID OUTPUT
---------- ----------------------------------------
1000A: b:c:d
1234 p:v:w:xthat just shows how stupidly data is as it should be divided every thing in the different elements so that you can then group to determine how many of each, you have (and whether to add or subtract) and then re - combine results again in a combined string.
Maybe you are looking for
-
print option block not available in the frames page
I tried to print this page http://www.nzherald.co.nz/ but FF does not allow me to print it as I see it. The printer produces all the columns in the order, but the Frame print options are grayed out. How can I get a reasonable reproduction of a page l
-
I lost the recovery on Satellite C50-B863 partition
Hello I tried to format my computer.I restart my computer then you press 0 and choose the configuration of the system and hard drive formats. When I restart my computer then press 0 once again, it does not work I did ' nt operating system find find!
-
Compatible for the cRIO 9063 VeriStand?
Hello I currently have Veristand 2014 installed, but I'm not able to install veristand engine to MAX. My 9063 cRIO is compatible for Veristand? Thank you
-
for Skype 6.11kb2876229 code 666 clerical error will not update
could someone please help with highest title
-
I can't dual boot my PC pre-installed Windows 7 with Windows XP?
I created a primary partition on my Windows 7 PC preinstalled in freeing up space. When I start my PC the Windows XP installation CD, Windows XP will in the usual configuration process by displaying the F6 option on the screen blue etc and it unloads