Need help with a query result
Oracle Version: 11.2.0.2.0
I need assistance with the output of the query. Here is the table.
With Tbl_Nm as
(
Select 'ABC1' SYSTEM_ID, REGION 'US', 'CHI' SUB_REGION 4000 BALANCE, to_date('1-JUN-2012 10:45:00 am', 'dd-mon-yyyy hh:mi:ss am') LAST_UPD_TIME, 'A' FLAG of union double all the
Select 'PQR2', 'UK', 'LN', 2000, To_Date('1-JUL-2012 10:46:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All
Select 'ABC1', 'IND","MAMA", 3500, To_Date('1-AUG-2012 11:47:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select "LMN3", "US", "NJ", 2500, To_Date('1-SEP-2012 09:49:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select "PQR2", "UK", "MC", 2600, To_Date('1-OCT-2012 04:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select 'ABC1', 'US', 'NY', 3200, To_Date('1-OCT-2012 06:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All
Select "LMN3", "UK", "BT", 2400, To_Date('1-NOV-2012 07:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' From Dual
)
Select * from tbl_nm
I need the output below.
PQR2 UK MC 2600 1 OCTOBER 2012 04:45
ABC1 US NY 3500 October 1, 2012 06:45
LMN3 UK BT 2500 November 1, 2012 07:45
The need the disc according to this system_id flagged as "A". But if the last disc of 'd' then it must show that the amount, but the file should be displayed in 'A '.
I've tried a few and got stuck. Help, please. Not able to get a balance '.
This question is a bit similar to needing help with a query result
With Tbl_Nm as
(
Select 'ABC1' System_Id, region 'US', 'CHI' Sub_Region, 4000 balance, To_Date('1-JUN-2012 10:45:00 am', 'dd-mon-yyyy hh:mi:ss am') Last_Upd_Time, 'A' flag of double Union All
Select 'PQR2', 'UK', 'LN', 2000, To_Date('1-JUL-2012 10:46:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All
Select 'ABC1', 'IND","MAMA", 3500, To_Date('1-AUG-2012 11:47:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select "LMN3", "US", "NJ", 2500, To_Date('1-SEP-2012 09:49:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select "PQR2", "UK", "MC", 2600, To_Date('1-OCT-2012 04:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select 'ABC1', 'US', 'NY', 3200, To_Date('1-OCT-2012 06:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All
Select "LMN3", "UK", "BT", 2400, To_Date('1-NOV-2012 07:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' From Dual
)
Select System_Id, region, Sub_Region, Balance, Last_Upd_Time of Tbl_Nm T1
where t1. Last_Upd_Time = (select max (Last_Upd_Time) in the Tbl_Nm T2 where T1.) SYSTEM_ID = T2. SYSTEM_ID)
So maybe you'd then
ORDER BY DECODE(flag,'D',9,1) ASC...
to get the Ds at the end of the list.
or
ORDER BY CASE WHAT flag = has ' (your other filters) AND then 9 or 1 end CSA,...
HTH
Tags: Database
Similar Questions
-
need help with the query, thx
Hello
I need a little help with the query I have to write;
the table has 4 columns:
what I am asking is the following result: salary according to the latest available yearcol1 col2 col3 col4 emp_name empl_id salary year content of data: col1 col2 col3 col4 smith 12 1200 1999 smith 12 1340 2000 smith 12 1500 2001 jones 13 1550 1999 jones 13 1600 2000 aron 14 1200 2002
i.e.
ID appreciate some guidance on how to achievesmith 12 1500 2001 jones 13 1600 2000 aron 14 1200 2002
Thank you
Rgdsselect *from (select col1, col2,col3, col4,row_number() over(partition by col1 order by col4 desc) rn from
) where rn=1 -
Need help with the query. Help, please
Hey everyone, need your help. Thank you in advance. In my view, there is function Pivot. Just do not know how to use this function. I have the query that works. The result is:
11-111-1111 Vlad 16505 01/04/2013 5 August 13 dental plan pre-tax amount 29,65
11-111-1111 Vlad 16505 01/04/2013 dental pre-tax 5 August 13 Plan level EE + SP
11-111-1111 16505 Vlad 01/04/2013 5 August 13 pre-tax Option TOP dental plan
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax dental care plan pay the value
11-111-1111 16505 Vlad 01/04/2013 dental pre-tax 5 August 13 Plan period Type
11-111-1111 Vlad 16505 01/04/2013 amount pre-tax medical Plan of 5 August 13 149
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Medical Plan level EE + SP
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Plan medical Option MED
11-111-1111 Vlad 16505 01/04/2013 5 August 13 plan pre-tax pay value
11-111-1111 16505 Vlad 01/04/2013 5 August 13 pre-tax Medical Plan period Type
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Plan PPO medical Plan
11-111-1111 Vlad 16505 01/04/2013 5 August 13 Vision Plan amount 5.94 pre-tax
But I need the result to be
Amount of SSN ID name item level Option PayValue period Type
11-111-1111 Vlad 16505 01/04/2013 null null high of 5 August 13 pre-tax Dental Plan 29,65 EE + SP
11-111-1111 Vlad 16505 01/04/2013 null null MED 5 August 13 149 medical plan pre-tax EE + SP
11-111-1111 Vlad 16505 01/04/2013 Vision Plan before taxes of 5 August 13
Select distinct
' 11-111-1111 "as ssn,
WOMEN'S WEAR. Employee_number,
"Vlad" as EMPLOYEE_FULL_NAME,
TO_CHAR (papf.start_date, "MM/DD/YYYY") as Date_Of_Hire
a.effective_start_date,
PETF.element_name,
pivf. Name,
peevf.screen_entry_valueOf
PER_all_PEOPLE_F women's wear
per_assignments_f A
pay_element_types_f petf
pay_element_links_f pelf
PAY_ELEMENT_ENTRIES_F penf
PAY_ELEMENT_ENTRY_VALUES_F peevf
pay_input_values_f pivf
WHERE
PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")
and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID
and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)
and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)
and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)
and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID
and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID
AND papf.employee_number IS NOT NULL
AND A.assignment_type = 'E '.
AND A.person_id = papf.person_id
and papf.effective_end_date > sysdate
and a.effective_end_date > sysdate
and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)
and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)
and a.assignment_id = 42643
and a.assignment_status_type_id = '1'
order of petf.element_name;Change with your query
SELECT * FROM (select distinct)
' 11-111-1111 "as ssn,
WOMEN'S WEAR. Employee_number,
"Vlad" as employee_full_name,
TO_CHAR (papf.start_date, "MM/DD/YYYY") as date_of_hire
a.effective_start_date,
PETF.element_name,
pivf. Name,
peevf.screen_entry_value
Of
PER_all_PEOPLE_F women's wear
per_assignments_f A
pay_element_types_f petf
pay_element_links_f pelf
PAY_ELEMENT_ENTRIES_F penf
PAY_ELEMENT_ENTRY_VALUES_F peevf
pay_input_values_f pivf
WHERE
PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")
and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID
and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)
and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)
and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)
and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID
and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID
AND papf.employee_number IS NOT NULL
AND A.assignment_type = 'E '.
AND A.person_id = papf.person_id
and papf.effective_end_date > sysdate
and a.effective_end_date > sysdate
and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)
and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)
and a.assignment_id = 42643
and a.assignment_status_type_id = '1')
PIVOT (MAX (screen_entry_value) FOR (name) TO ("Amount" AS 'Amount', 'level' AS 'level', 'Option High' AS 'High Option', 'Pay the value' AS 'Value to pay', 'Period of Type' AS 'Type period'))
order by element_name;
(GOLD)
SELECT ssn,
Employee_number,
employee_full_name,
date_of_hire,
effective_start_date,
element_name,
Max (decode (Name, 'Amount', screen_entry_value)) 'amount. "
Max (decode (Name, 'Level', screen_entry_value)) 'level ',.
MAX (DECODE (name, "High Option", screen_entry_value)) "High Option",
MAX (DECODE (name, 'Value of pay', screen_entry_value)) 'value of pay. "
MAX (DECODE (name, 'Period Type', screen_entry_value)) 'period of Type '.
FROM (select distinct)
' 11-111-1111 "as ssn,
WOMEN'S WEAR. Employee_number,
"Vlad" as employee_full_name,
TO_CHAR (papf.start_date, "MM/DD/YYYY") as date_of_hire
a.effective_start_date,
PETF.element_name,
pivf. Name,
peevf.screen_entry_value
Of
PER_all_PEOPLE_F women's wear
per_assignments_f A
pay_element_types_f petf
pay_element_links_f pelf
PAY_ELEMENT_ENTRIES_F penf
PAY_ELEMENT_ENTRY_VALUES_F peevf
pay_input_values_f pivf
WHERE
PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")
and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID
and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)
and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)
and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)
and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID
and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID
AND papf.employee_number IS NOT NULL
AND A.assignment_type = 'E '.
AND A.person_id = papf.person_id
and papf.effective_end_date > sysdate
and a.effective_end_date > sysdate
and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)
and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)
and a.assignment_id = 42643
and a.assignment_status_type_id = '1')
GROUP BY ssn, employee_number, employee_full_name, date_of_hire, effective_start_date, NOM_ELEMENT
order by element_name;
-
Need help with SQL Query - change of name history of audit table.
I need your help to find the result in the following way...
Emp No New_name Old_Name ----------------------------------------------- 1 Name3 Name2 1 Name2 Name1
Thank you...create table emp(emp_id number(10), emp_name varchar(50), constraints emp_pk primary key(emp_id) ); create table emp_audit( audit_id number(10), emp_id number(10), emp_name varchar(50), audit_date date, constraints emp_audit_pk primary key (audit_id), constraints emp_audit_emp_fk foreign key(emp_id) references emp(emp_id)); insert into emp values(1,'Name3'); insert into EMP_AUDIT (audit_id, emp_id, emp_name, audit_date) values (1, 1, 'Name1', to_date('14-08-2011', 'dd-mm-yyyy')); insert into EMP_AUDIT (audit_id, emp_id, emp_name, audit_date) values (2, 1, 'Name2', to_date('15-08-2011', 'dd-mm-yyyy')); commit;
Dipabkar Bédard (DB) wrote:
We write is the query without using "partition by" in oracle...?
with t as ( select audit_id, emp_id, emp_name, row_number() over(order by audit_id) rn from emp_audit order by emp_id, audit_id ) select a.audit_id, a.emp_id, a.emp_name old_name, nvl(b.emp_name,(select c.emp_name from emp c where c.emp_id = a.emp_id)) new_name from t a left join t b on ( b.emp_id = a.emp_id and b.rn = a.rn + 1 ) / AUDIT_ID EMP_ID OLD_NAME NEW_NAME ---------- ---------- -------------------------------------------------- ------------ 1 1 Name1 Name2 2 1 Name2 Name3 SQL>
And without analytical functions:
with t1 as ( select audit_id, emp_id, emp_name from emp_audit order by emp_id, audit_id ), t2 as ( select audit_id, emp_id, emp_name, rownum rn from t1 ) select a.audit_id, a.emp_id, a.emp_name old_name, nvl(b.emp_name,(select c.emp_name from emp c where c.emp_id = a.emp_id)) new_name from t2 a left join t2 b on ( b.emp_id = a.emp_id and b.rn = a.rn + 1 ) / AUDIT_ID EMP_ID OLD_NAME NEW_NAME ---------- ---------- -------------------------------------------------- ---------- 1 1 Name1 Name2 2 1 Name2 Name3 SQL>
SY.
-
Need help with a query to group by return qroups with no result
I have the following query that checks the number of items maintenance has been done for each paragraph in a support order.
It lists all the paragraphs being checked it and the number of maintenance activities were conducted for that paragraph.
It works very well in most of the cases, except some of the facilities to break their equipment into subcatagories from a specific facility specified in the lpm.equipment_ident field.
For example, the tables and the data below are for the installation of ATL, which is breaking down for channels A and B maintenance activities
The following query illustrates 10 maintenance activities for installation ATL and the query must be 5 for ATL channel A and 5 activities for ATL channel B
This is the query, output current, output desired and all the SQL required to create the tables and data. I am using Oracle 11g
Any help would be appreciated.
-- Query SELECT req.publication_paragraph_number AS publication_paragraph -- , req.description , req.frequency , case upper (req.frequency) WHEN 'DAILY' THEN 365 WHEN 'WEEKLY' THEN 52 WHEN 'MONTHLY' THEN 12 WHEN 'QUARTERLY' THEN 4 WHEN 'SEMIANNUALLY' THEN 2 WHEN 'ANNUALLY' THEN 1 ELSE 0 END as num_req, MAX(lpm.equipment_ident) AS equipment_ident , COUNT(fsep.fac_id) as activities_performed FROM pm_requirements_table req LEFT OUTER JOIN lpm_paragraph_mapping_table pmap ON req.publication_order = pmap.publication_order AND req.publication_paragraph_number = pmap.publication_paragraph LEFT OUTER JOIN lpm ON trim(lpm.publication_paragraph) = pmap.paragraph_alias_mapping AND TRIM(lpm.publication_order) = '6310.19A' AND TRUNC(lpm.start_date, 'YEAR') = TO_DATE('01/01/2010', 'MM/DD/YYYY') AND lpm.fac_ident = 'ATL' LEFT OUTER JOIN fsep ON fsep.fac_id = lpm.fac_ident AND fsep.facility = lpm.fac_type GROUP BY req.publication_paragraph_number, req.description, req.frequency ORDER BY req.publication_paragraph_number;
-- Current Output "PUBLICATION_PARAGRAPH" "FREQUENCY" "NUM_REQ" "EQUIPMENT_IDENT" "ACTIVITIES_PERFORMED" "161A" "WEEKLY" "52" "CHAN B" "10" "161B" "WEEKLY" "52" "CHAN B" "10" "161C" "WEEKLY" "52" "CHAN B" "10" "161D(1)" "WEEKLY" "52" "" "0" "161D(2)" "WEEKLY" "52" "" "0" "161D(3)" "WEEKLY" "52" "" "0" "161D(4)" "WEEKLY" "52" "" "0" "161D(5)" "WEEKLY" "52" "" "0" "161D(6)" "WEEKLY" "52" "" "0" "161E" "WEEKLY" "52" "" "0" "161F" "WEEKLY" "52" "" "0" "161G" "WEEKLY" "52" "" "0" "161H" "WEEKLY" "52" "" "0" "161I" "WEEKLY" "52" "" "0" "161J" "WEEKLY" "52" "" "0" "161K" "WEEKLY" "52" "" "0"
-- Desired Output "PUBLICATION_PARAGRAPH" "FREQUENCY" "NUM_REQ" "EQUIPMENT_IDENT" "ACTIVITIES_PERFORMED" "161A" "WEEKLY" "52" "CHAN A" "5" "161A" "WEEKLY" "52" "CHAN B" "5" "161B" "WEEKLY" "52" "CHAN A" "5" "161B" "WEEKLY" "52" "CHAN B" "5" "161C" "WEEKLY" "52" "CHAN A" "5" "161C" "WEEKLY" "52" "CHAN B" "5" "161D(1)" "WEEKLY" "52" "" "0" "161D(2)" "WEEKLY" "52" "" "0" "161D(3)" "WEEKLY" "52" "" "0" "161D(4)" "WEEKLY" "52" "" "0" "161D(5)" "WEEKLY" "52" "" "0" "161D(6)" "WEEKLY" "52" "" "0" "161E" "WEEKLY" "52" "" "0" "161F" "WEEKLY" "52" "" "0" "161G" "WEEKLY" "52" "" "0" "161H" "WEEKLY" "52" "" "0" "161I" "WEEKLY" "52" "" "0" "161J" "WEEKLY" "52" "" "0" "161K" "WEEKLY" "52" "" "0"
Published by: George Heller on July 20, 2011 13:45-- Tables and Data CREATE TABLE "LPM" ( "LOG_ID" NUMBER(22,0) NOT NULL ENABLE, "FAC_IDENT" VARCHAR2(5 BYTE), "FAC_TYPE" VARCHAR2(5 BYTE), "CODE_CATEGORY" NUMBER(22,0) NOT NULL ENABLE, "SUPPLEMENTAL_CODE" VARCHAR2(1 BYTE), "MAINT_ACTION_CODE" VARCHAR2(1 BYTE), "INTERRUPT_CONDITION" VARCHAR2(22 BYTE), "ATOW_CODE" VARCHAR2(22 BYTE), "SECTOR_CODE" VARCHAR2(5 BYTE), "LOG_STATUS" VARCHAR2(3 BYTE) NOT NULL ENABLE, "START_DATE" DATE, "START_DATETIME" VARCHAR2(22 BYTE), "END_DATE" DATE, "END_DATETIME" VARCHAR2(22 BYTE), "MODIFIED_DATETIME" VARCHAR2(22 BYTE), "WR_AREA" VARCHAR2(6 BYTE), "SHORT_NAME" VARCHAR2(15 BYTE), "EQUIPMENT_IDENT" VARCHAR2(15 BYTE), "INTERVAL_CODE" VARCHAR2(255 BYTE), "EARLIEST_DATE" VARCHAR2(4000 BYTE), "EARLIEST_DATETIME" VARCHAR2(255 BYTE), "SCHEDULED_DATE" DATE, "SCHEDULED_DATETIME" VARCHAR2(22 BYTE), "LATEST_DATE" DATE, "LATEST_DATETIME" VARCHAR2(22 BYTE), "WR_CREW_UNIT" VARCHAR2(10 BYTE), "WR_WATCH" VARCHAR2(1 BYTE), "PUBLICATION_ORDER" VARCHAR2(30 BYTE), "PUBLICATION_ORDER_ORIGINAL" VARCHAR2(30 BYTE), "PUBLICATION_PARAGRAPH" VARCHAR2(30 BYTE), "PUBLICATION_PARAGRAPH_ORIGINAL" VARCHAR2(30 BYTE), "NUMBER_OF_TASKS" VARCHAR2(25 BYTE), "LOG_SUMMARY" VARCHAR2(255 BYTE), "COMMENTS" CLOB, "RELATED_LOGS" CLOB, "LPMANTAC_ID" NUMBER ); CREATE TABLE "FSEP" ( "FAC_ID" VARCHAR2(10 BYTE), "FACILITY" VARCHAR2(5 BYTE), "FAC_LOCATION" VARCHAR2(13 BYTE), "FAC_STATE" VARCHAR2(2 BYTE), "REGION" VARCHAR2(2 BYTE), "COST_CENTER" VARCHAR2(8 BYTE) NOT NULL ENABLE, "ATOW_ORG" VARCHAR2(150 BYTE), "ATOW_ORG_DESCRIPTION" VARCHAR2(150 BYTE), "SVC_AREA" VARCHAR2(5 BYTE), "SECTOR_CODE" VARCHAR2(5 BYTE), "FAC_CODE" VARCHAR2(20 BYTE), "FAC_STATUS" CHAR(1 BYTE) NOT NULL ENABLE, "RESTORATION_CODE" VARCHAR2(2 BYTE), "RESPONSIBILITY_CODE" CHAR(1 BYTE), "POWER_CODE" CHAR(1 BYTE), "FAC_STATUS_DATE" DATE, "FAC_SWAP_DATE" DATE, "CHANGE_DATE" VARCHAR2(22 BYTE), "GSA_ADDRESS" VARCHAR2(15 BYTE), "INV" VARCHAR2(2 BYTE), "SDP_TYPE" VARCHAR2(5 BYTE), "SDP_IDENT" VARCHAR2(4 BYTE), "CONTROL_IDENT" VARCHAR2(10 BYTE), "REMOTE_IDENT" VARCHAR2(10 BYTE), "MONITOR_IDENT" VARCHAR2(4 BYTE), "RUNWAY" VARCHAR2(3 BYTE), "ASSOC_AIRPORT" VARCHAR2(4 BYTE), "FAC_MPS_SITE" CHAR(4 BYTE), "FREQS_IN_PLACE" NUMBER(22,0), "CONGRESSIONAL_DIS" VARCHAR2(2 BYTE), "CONTRACT_MAINT_PER" NUMBER(22,0), "AIR_COND" CHAR(1 BYTE), "FAC_UNITS" NUMBER(22,0), "ET_PRIMARY_IDENT" VARCHAR2(4 BYTE), "ET_PRIMARY_TYPE" VARCHAR2(5 BYTE), "ENV_PRIMARY_IDENT" VARCHAR2(4 BYTE), "ENV_PRIMARY_TYPE" VARCHAR2(5 BYTE), "FAC_CODE_DESC" VARCHAR2(100 BYTE), "STATUS_DESC" VARCHAR2(50 BYTE), "RESTORATION_DESC" VARCHAR2(32 BYTE), "POWER_DESC" VARCHAR2(500 BYTE), "LATITUDE" VARCHAR2(150 BYTE), "LONGITUDE" VARCHAR2(150 BYTE), "ELEVATION" VARCHAR2(22 BYTE), "MOD_COUNT" VARCHAR2(22 BYTE), "HYPERLINK" VARCHAR2(255 BYTE), "FSEPANTAC_ID" NUMBER ); CREATE TABLE "LPM_PARAGRAPH_MAPPING_TABLE" ( "PUBLICATION_ORDER" VARCHAR2(30 BYTE), "PUBLICATION_PARAGRAPH" VARCHAR2(30 BYTE), "PARAGRAPH_ALIAS_MAPPING" VARCHAR2(30 BYTE), "LPMTANTAC_ID" NUMBER ); CREATE TABLE "PM_REQUIREMENTS_TABLE" ( "PUBLICATION_ORDER" VARCHAR2(30 BYTE), "PUBLICATION_PARAGRAPH_NUMBER" VARCHAR2(30 BYTE), "DESCRIPTION" VARCHAR2(4000 BYTE), "FREQUENCY" VARCHAR2(30 BYTE), "CHECK_OR_MAINTENANCE" VARCHAR2(22 BYTE), "PRTANTAC_ID" NUMBER); Insert into lpm (LOG_ID,FAC_IDENT,FAC_TYPE,CODE_CATEGORY,SUPPLEMENTAL_CODE,MAINT_ACTION_CODE,INTERRUPT_CONDITION,ATOW_CODE,SECTOR_CODE,LOG_STATUS,START_DATE,START_DATETIME,END_DATE,END_DATETIME,MODIFIED_DATETIME,WR_AREA,SHORT_NAME,EQUIPMENT_IDENT,INTERVAL_CODE,EARLIEST_DATE,EARLIEST_DATETIME,SCHEDULED_DATE,SCHEDULED_DATETIME,LATEST_DATE,LATEST_DATETIME,WR_CREW_UNIT,WR_WATCH,PUBLICATION_ORDER,PUBLICATION_ORDER_ORIGINAL,PUBLICATION_PARAGRAPH,PUBLICATION_PARAGRAPH_ORIGINAL,NUMBER_OF_TASKS,LOG_SUMMARY,COMMENTS,RELATED_LOGS,LPMANTAC_ID) values (108306002,'ATL','ASR',50,'0','P',null,'WEQ1C','SO1LB','C',to_date('02-MAY-10','DD-MON-RR'),'05/02/2010 21:00',to_date('02-MAY-10','DD-MON-RR'),'05/02/2010 21:30','05/03/2010 1:07','RADAR','SYS','CHAN B','W','05/02/2010','05/02/2010 0:00',to_date('05-MAY-10','DD-MON-RR'),'05/05/2010 0:00',to_date('08-MAY-10','DD-MON-RR'),'05/08/2010 0:00','RADR',null,'6310.19A','6310.19A','161A-J','161 A-J','15',null, EMPTY_CLOB(), EMPTY_CLOB(),14297); Insert into lpm (LOG_ID,FAC_IDENT,FAC_TYPE,CODE_CATEGORY,SUPPLEMENTAL_CODE,MAINT_ACTION_CODE,INTERRUPT_CONDITION,ATOW_CODE,SECTOR_CODE,LOG_STATUS,START_DATE,START_DATETIME,END_DATE,END_DATETIME,MODIFIED_DATETIME,WR_AREA,SHORT_NAME,EQUIPMENT_IDENT,INTERVAL_CODE,EARLIEST_DATE,EARLIEST_DATETIME,SCHEDULED_DATE,SCHEDULED_DATETIME,LATEST_DATE,LATEST_DATETIME,WR_CREW_UNIT,WR_WATCH,PUBLICATION_ORDER,PUBLICATION_ORDER_ORIGINAL,PUBLICATION_PARAGRAPH,PUBLICATION_PARAGRAPH_ORIGINAL,NUMBER_OF_TASKS,LOG_SUMMARY,COMMENTS,RELATED_LOGS,LPMANTAC_ID) values (108306102,'ATL','ASR',50,'0','P',null,'WEQ1C','SO1LB','C',to_date('02-MAY-10','DD-MON-RR'),'05/02/2010 21:00',to_date('02-MAY-10','DD-MON-RR'),'05/02/2010 21:30','05/03/2010 1:07','RADAR','SYS','CHAN A','W','05/02/2010','05/02/2010 0:00',to_date('05-MAY-10','DD-MON-RR'),'05/05/2010 0:00',to_date('08-MAY-10','DD-MON-RR'),'05/08/2010 0:00','RADR',null,'6310.19A','6310.19A','161A-J','161 A-J','15',null, EMPTY_CLOB(), EMPTY_CLOB(),14298); Insert into lpm (LOG_ID,FAC_IDENT,FAC_TYPE,CODE_CATEGORY,SUPPLEMENTAL_CODE,MAINT_ACTION_CODE,INTERRUPT_CONDITION,ATOW_CODE,SECTOR_CODE,LOG_STATUS,START_DATE,START_DATETIME,END_DATE,END_DATETIME,MODIFIED_DATETIME,WR_AREA,SHORT_NAME,EQUIPMENT_IDENT,INTERVAL_CODE,EARLIEST_DATE,EARLIEST_DATETIME,SCHEDULED_DATE,SCHEDULED_DATETIME,LATEST_DATE,LATEST_DATETIME,WR_CREW_UNIT,WR_WATCH,PUBLICATION_ORDER,PUBLICATION_ORDER_ORIGINAL,PUBLICATION_PARAGRAPH,PUBLICATION_PARAGRAPH_ORIGINAL,NUMBER_OF_TASKS,LOG_SUMMARY,COMMENTS,RELATED_LOGS,LPMANTAC_ID) values (104188402,'ATL','ASR',50,'0','P',null,'WEQ1C','SO1LB','C',to_date('26-APR-10','DD-MON-RR'),'4/26/2010 13:33',to_date('26-APR-10','DD-MON-RR'),'4/26/2010 13:46','4/26/2010 15:23','RADAR','SYS','CHAN A','W','4/25/2010','4/25/2010 0:00',to_date('28-APR-10','DD-MON-RR'),'4/28/2010 0:00',to_date('01-MAY-10','DD-MON-RR'),'05/01/2010 0:00','RADR',null,'6310.19A','6310.19A','161A-J','161 A-J','15',null, EMPTY_CLOB(), EMPTY_CLOB(),14306); Insert into lpm (LOG_ID,FAC_IDENT,FAC_TYPE,CODE_CATEGORY,SUPPLEMENTAL_CODE,MAINT_ACTION_CODE,INTERRUPT_CONDITION,ATOW_CODE,SECTOR_CODE,LOG_STATUS,START_DATE,START_DATETIME,END_DATE,END_DATETIME,MODIFIED_DATETIME,WR_AREA,SHORT_NAME,EQUIPMENT_IDENT,INTERVAL_CODE,EARLIEST_DATE,EARLIEST_DATETIME,SCHEDULED_DATE,SCHEDULED_DATETIME,LATEST_DATE,LATEST_DATETIME,WR_CREW_UNIT,WR_WATCH,PUBLICATION_ORDER,PUBLICATION_ORDER_ORIGINAL,PUBLICATION_PARAGRAPH,PUBLICATION_PARAGRAPH_ORIGINAL,NUMBER_OF_TASKS,LOG_SUMMARY,COMMENTS,RELATED_LOGS,LPMANTAC_ID) values (104188502,'ATL','ASR',50,'0','P',null,'WEQ1C','SO1LB','C',to_date('26-APR-10','DD-MON-RR'),'4/26/2010 13:33',to_date('26-APR-10','DD-MON-RR'),'4/26/2010 13:46','4/26/2010 15:23','RADAR','SYS','CHAN B','W','4/25/2010','4/25/2010 0:00',to_date('28-APR-10','DD-MON-RR'),'4/28/2010 0:00',to_date('01-MAY-10','DD-MON-RR'),'05/01/2010 0:00','RADR',null,'6310.19A','6310.19A','161A-J','161 A-J','15',null, EMPTY_CLOB(), EMPTY_CLOB(),14307); Insert into lpm (LOG_ID,FAC_IDENT,FAC_TYPE,CODE_CATEGORY,SUPPLEMENTAL_CODE,MAINT_ACTION_CODE,INTERRUPT_CONDITION,ATOW_CODE,SECTOR_CODE,LOG_STATUS,START_DATE,START_DATETIME,END_DATE,END_DATETIME,MODIFIED_DATETIME,WR_AREA,SHORT_NAME,EQUIPMENT_IDENT,INTERVAL_CODE,EARLIEST_DATE,EARLIEST_DATETIME,SCHEDULED_DATE,SCHEDULED_DATETIME,LATEST_DATE,LATEST_DATETIME,WR_CREW_UNIT,WR_WATCH,PUBLICATION_ORDER,PUBLICATION_ORDER_ORIGINAL,PUBLICATION_PARAGRAPH,PUBLICATION_PARAGRAPH_ORIGINAL,NUMBER_OF_TASKS,LOG_SUMMARY,COMMENTS,RELATED_LOGS,LPMANTAC_ID) values (101223702,'ATL','ASR',50,'0','P',null,'WEQ1C','SO1LB','C',to_date('19-APR-10','DD-MON-RR'),'4/19/2010 1:30',to_date('19-APR-10','DD-MON-RR'),'4/19/2010 2:10','4/19/2010 3:12','RADAR','SYS','CHAN B','W','4/18/2010','4/18/2010 0:00',to_date('21-APR-10','DD-MON-RR'),'4/21/2010 0:00',to_date('24-APR-10','DD-MON-RR'),'4/24/2010 0:00','RADR',null,'6310.19A','6310.19A','161A-J','161 A-J','15',null, EMPTY_CLOB(), EMPTY_CLOB(),14322); Insert into lpm (LOG_ID,FAC_IDENT,FAC_TYPE,CODE_CATEGORY,SUPPLEMENTAL_CODE,MAINT_ACTION_CODE,INTERRUPT_CONDITION,ATOW_CODE,SECTOR_CODE,LOG_STATUS,START_DATE,START_DATETIME,END_DATE,END_DATETIME,MODIFIED_DATETIME,WR_AREA,SHORT_NAME,EQUIPMENT_IDENT,INTERVAL_CODE,EARLIEST_DATE,EARLIEST_DATETIME,SCHEDULED_DATE,SCHEDULED_DATETIME,LATEST_DATE,LATEST_DATETIME,WR_CREW_UNIT,WR_WATCH,PUBLICATION_ORDER,PUBLICATION_ORDER_ORIGINAL,PUBLICATION_PARAGRAPH,PUBLICATION_PARAGRAPH_ORIGINAL,NUMBER_OF_TASKS,LOG_SUMMARY,COMMENTS,RELATED_LOGS,LPMANTAC_ID) values (101223802,'ATL','ASR',50,'0','P',null,'WEQ1C','SO1LB','C',to_date('19-APR-10','DD-MON-RR'),'4/19/2010 1:30',to_date('19-APR-10','DD-MON-RR'),'4/19/2010 2:10','4/19/2010 3:12','RADAR','SYS','CHAN A','W','4/18/2010','4/18/2010 0:00',to_date('21-APR-10','DD-MON-RR'),'4/21/2010 0:00',to_date('24-APR-10','DD-MON-RR'),'4/24/2010 0:00','RADR',null,'6310.19A','6310.19A','161A-J','161 A-J','15',null, EMPTY_CLOB(), EMPTY_CLOB(),14323); Insert into lpm (LOG_ID,FAC_IDENT,FAC_TYPE,CODE_CATEGORY,SUPPLEMENTAL_CODE,MAINT_ACTION_CODE,INTERRUPT_CONDITION,ATOW_CODE,SECTOR_CODE,LOG_STATUS,START_DATE,START_DATETIME,END_DATE,END_DATETIME,MODIFIED_DATETIME,WR_AREA,SHORT_NAME,EQUIPMENT_IDENT,INTERVAL_CODE,EARLIEST_DATE,EARLIEST_DATETIME,SCHEDULED_DATE,SCHEDULED_DATETIME,LATEST_DATE,LATEST_DATETIME,WR_CREW_UNIT,WR_WATCH,PUBLICATION_ORDER,PUBLICATION_ORDER_ORIGINAL,PUBLICATION_PARAGRAPH,PUBLICATION_PARAGRAPH_ORIGINAL,NUMBER_OF_TASKS,LOG_SUMMARY,COMMENTS,RELATED_LOGS,LPMANTAC_ID) values (96642402,'ATL','ASR',50,'0','P',null,'WEQ1C','SO1LB','C',to_date('11-APR-10','DD-MON-RR'),'04/11/2010 11:10',to_date('11-APR-10','DD-MON-RR'),'04/11/2010 11:15','04/11/2010 12:51','RADAR','SYS','CHAN B','W','04/11/2010','04/11/2010 0:00',to_date('14-APR-10','DD-MON-RR'),'4/14/2010 0:00',to_date('17-APR-10','DD-MON-RR'),'4/17/2010 0:00','RADR',null,'6310.19A','6310.19A','161A-J','161 A-J','15',null, EMPTY_CLOB(), EMPTY_CLOB(),14335); Insert into lpm (LOG_ID,FAC_IDENT,FAC_TYPE,CODE_CATEGORY,SUPPLEMENTAL_CODE,MAINT_ACTION_CODE,INTERRUPT_CONDITION,ATOW_CODE,SECTOR_CODE,LOG_STATUS,START_DATE,START_DATETIME,END_DATE,END_DATETIME,MODIFIED_DATETIME,WR_AREA,SHORT_NAME,EQUIPMENT_IDENT,INTERVAL_CODE,EARLIEST_DATE,EARLIEST_DATETIME,SCHEDULED_DATE,SCHEDULED_DATETIME,LATEST_DATE,LATEST_DATETIME,WR_CREW_UNIT,WR_WATCH,PUBLICATION_ORDER,PUBLICATION_ORDER_ORIGINAL,PUBLICATION_PARAGRAPH,PUBLICATION_PARAGRAPH_ORIGINAL,NUMBER_OF_TASKS,LOG_SUMMARY,COMMENTS,RELATED_LOGS,LPMANTAC_ID) values (96642302,'ATL','ASR',50,'0','P',null,'WEQ1C','SO1LB','C',to_date('11-APR-10','DD-MON-RR'),'04/11/2010 11:05',to_date('11-APR-10','DD-MON-RR'),'04/11/2010 11:10','04/11/2010 12:51','RADAR','SYS','CHAN A','W','04/11/2010','04/11/2010 0:00',to_date('14-APR-10','DD-MON-RR'),'4/14/2010 0:00',to_date('17-APR-10','DD-MON-RR'),'4/17/2010 0:00','RADR',null,'6310.19A','6310.19A','161A-J','161 A-J','15',null, EMPTY_CLOB(), EMPTY_CLOB(),14336); Insert into lpm (LOG_ID,FAC_IDENT,FAC_TYPE,CODE_CATEGORY,SUPPLEMENTAL_CODE,MAINT_ACTION_CODE,INTERRUPT_CONDITION,ATOW_CODE,SECTOR_CODE,LOG_STATUS,START_DATE,START_DATETIME,END_DATE,END_DATETIME,MODIFIED_DATETIME,WR_AREA,SHORT_NAME,EQUIPMENT_IDENT,INTERVAL_CODE,EARLIEST_DATE,EARLIEST_DATETIME,SCHEDULED_DATE,SCHEDULED_DATETIME,LATEST_DATE,LATEST_DATETIME,WR_CREW_UNIT,WR_WATCH,PUBLICATION_ORDER,PUBLICATION_ORDER_ORIGINAL,PUBLICATION_PARAGRAPH,PUBLICATION_PARAGRAPH_ORIGINAL,NUMBER_OF_TASKS,LOG_SUMMARY,COMMENTS,RELATED_LOGS,LPMANTAC_ID) values (92805502,'ATL','ASR',50,'0','P',null,'WEQ1C','SO1LB','C',to_date('07-APR-10','DD-MON-RR'),'04/07/2010 18:10',to_date('07-APR-10','DD-MON-RR'),'04/07/2010 18:22','04/07/2010 19:04','RADAR','SYS','CHAN A','W','04/04/2010','04/04/2010 0:00',to_date('07-APR-10','DD-MON-RR'),'04/07/2010 0:00',to_date('10-APR-10','DD-MON-RR'),'04/10/2010 0:00','RADR',null,'6310.19A','6310.19A','161A-J','161 A-J','15',null, EMPTY_CLOB(), EMPTY_CLOB(),14342); Insert into lpm (LOG_ID,FAC_IDENT,FAC_TYPE,CODE_CATEGORY,SUPPLEMENTAL_CODE,MAINT_ACTION_CODE,INTERRUPT_CONDITION,ATOW_CODE,SECTOR_CODE,LOG_STATUS,START_DATE,START_DATETIME,END_DATE,END_DATETIME,MODIFIED_DATETIME,WR_AREA,SHORT_NAME,EQUIPMENT_IDENT,INTERVAL_CODE,EARLIEST_DATE,EARLIEST_DATETIME,SCHEDULED_DATE,SCHEDULED_DATETIME,LATEST_DATE,LATEST_DATETIME,WR_CREW_UNIT,WR_WATCH,PUBLICATION_ORDER,PUBLICATION_ORDER_ORIGINAL,PUBLICATION_PARAGRAPH,PUBLICATION_PARAGRAPH_ORIGINAL,NUMBER_OF_TASKS,LOG_SUMMARY,COMMENTS,RELATED_LOGS,LPMANTAC_ID) values (92805402,'ATL','ASR',50,'0','P',null,'WEQ1C','SO1LB','C',to_date('07-APR-10','DD-MON-RR'),'04/07/2010 17:53',to_date('07-APR-10','DD-MON-RR'),'04/07/2010 18:05','04/07/2010 19:04','RADAR','SYS','CHAN B','W','04/04/2010','04/04/2010 0:00',to_date('07-APR-10','DD-MON-RR'),'04/07/2010 0:00',to_date('10-APR-10','DD-MON-RR'),'04/10/2010 0:00','RADR',null,'6310.19A','6310.19A','161A-J','161 A-J','15',null, EMPTY_CLOB(), EMPTY_CLOB(),14343); Insert into fsep (FAC_ID,FACILITY,FAC_LOCATION,FAC_STATE,REGION,COST_CENTER,ATOW_ORG,ATOW_ORG_DESCRIPTION,SVC_AREA,SECTOR_CODE,FAC_CODE,FAC_STATUS,RESTORATION_CODE,RESPONSIBILITY_CODE,POWER_CODE,FAC_STATUS_DATE,FAC_SWAP_DATE,CHANGE_DATE,GSA_ADDRESS,INV,SDP_TYPE,SDP_IDENT,CONTROL_IDENT,REMOTE_IDENT,MONITOR_IDENT,RUNWAY,ASSOC_AIRPORT,FAC_MPS_SITE,FREQS_IN_PLACE,CONGRESSIONAL_DIS,CONTRACT_MAINT_PER,AIR_COND,FAC_UNITS,ET_PRIMARY_IDENT,ET_PRIMARY_TYPE,ENV_PRIMARY_IDENT,ENV_PRIMARY_TYPE,FAC_CODE_DESC,STATUS_DESC,RESTORATION_DESC,POWER_DESC,LATITUDE,LONGITUDE,ELEVATION,MOD_COUNT,HYPERLINK,FSEPANTAC_ID) values ('ATL','ASR','ATLANTA','GA','SO','081LB','WEQ1C','Hartsfield Radar SSC','ESA','SO1LB','453ACA','D','4','A','A',to_date('01-OCT-50','DD-MON-RR'),to_date('01-OCT-95','DD-MON-RR'),'11/17/2010 8:51','43JW','RD','TRACO','A80','A80','ATL','A80',null,'ATL','ZTL ',0,'5',0,'A',1,null,null,null,null,'ASR-9 STANDARD FACILITY','Commissioned/Full Service','Up to 4 Hours','Denotes a commercial power source a standby engine generator and an Uninterruptible Power Supply (UPS). This configuration shall provide uninterruptible conditioned power with AC voltage in and AC voltage out.','33.62875','-8.43003','1030','2','http://technet.faa.gov/fsep/fsepDetail.asp?recordno=ASRATL',32084); Insert into fsep (FAC_ID,FACILITY,FAC_LOCATION,FAC_STATE,REGION,COST_CENTER,ATOW_ORG,ATOW_ORG_DESCRIPTION,SVC_AREA,SECTOR_CODE,FAC_CODE,FAC_STATUS,RESTORATION_CODE,RESPONSIBILITY_CODE,POWER_CODE,FAC_STATUS_DATE,FAC_SWAP_DATE,CHANGE_DATE,GSA_ADDRESS,INV,SDP_TYPE,SDP_IDENT,CONTROL_IDENT,REMOTE_IDENT,MONITOR_IDENT,RUNWAY,ASSOC_AIRPORT,FAC_MPS_SITE,FREQS_IN_PLACE,CONGRESSIONAL_DIS,CONTRACT_MAINT_PER,AIR_COND,FAC_UNITS,ET_PRIMARY_IDENT,ET_PRIMARY_TYPE,ENV_PRIMARY_IDENT,ENV_PRIMARY_TYPE,FAC_CODE_DESC,STATUS_DESC,RESTORATION_DESC,POWER_DESC,LATITUDE,LONGITUDE,ELEVATION,MOD_COUNT,HYPERLINK,FSEPANTAC_ID) values ('ATL','GS','ATLANTA','GA','SO','081MB','WEQ1A','Hartsfield Nav/Comm SSC','ESA','SO1MB','314JAH','D','24','A','D',to_date('18-NOV-49','DD-MON-RR'),to_date('01-DEC-96','DD-MON-RR'),'3/4/2009 14:40','43JX','21','ATCT','ATL','ATL',null,'A80','08R','ATL','ZTL ',0,'5',0,'A',1,null,null,null,null,'MARK 20 CAPTURE EFFECT CAT III W/RMM','Commissioned/Full Service','Up to 24 Hours','Denotes a commercial power source and a battery standby power system. A UPS is not included in this category.','33.64788','-84.43426','1012','2','http://technet.faa.gov/fsep/fsepDetail.asp?recordno=GSATL',32109); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161A','161',1708); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161A','161A-J',1709); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161B','161',1736); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161B','161A-J',1737); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161C','161',1765); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161C','161A-J',1766); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161C','161(A-->K)',1769); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161C','161(A-K)',1774); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161C','161.(A-C).',1775); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161D(1)','161',1793); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161D(1)','161161 A-J',1794); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161D(2)','161',1821); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161D(2)','161 A-J',1822); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161D(2)','161(A-->K)',1825); Insert into LPM_PARAGRAPH_MAPPING_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH,PARAGRAPH_ALIAS_MAPPING,LPMTANTAC_ID) values ('6310.19A','161K','161.K',1825); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161A','Check transmitter average rf power output','WEEKLY',null,3); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161B','Check transmitter VSWR','WEEKLY',null,4); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161C','Check RMS transmitter pulse width','WEEKLY',null,5); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161D(1)','Check filament current','WEEKLY',null,6); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161D(2)','Check focus coil current','WEEKLY',null,7); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161D(3)','Check Klystron voltage','WEEKLY',null,8); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161D(4)','Check Klystron current','WEEKLY',null,9); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161D(5)','Check PFN voltage','WEEKLY',null,10); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161D(6)','Check vacuum pump current','WEEKLY',null,11); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161E','Check target receiver MDS','WEEKLY',null,12); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161F','Check target receiver NF','WEEKLY',null,13); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161G','Check target receiver recovery','WEEKLY',null,14); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161H','Check weather receiver MDS','WEEKLY',null,15); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161I','Check weather receiver NF','WEEKLY',null,16); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161J','Check weather receiver recovery','WEEKLY',null,17); Insert into PM_REQUIREMENTS_TABLE (PUBLICATION_ORDER,PUBLICATION_PARAGRAPH_NUMBER,DESCRIPTION,FREQUENCY,CHECK_OR_MAINTENANCE,PRTANTAC_ID) values ('6310.19A','161K','Check spare modem operation','WEEKLY',null,18);
Published by: George Heller on July 20, 2011 13:46
Published by: George Heller on July 20, 2011 13:48Hi, George.
I think I understand now!
You want outer join table req on the result of all the other joined tables. You want all the lines of the req to be represented in the result set, even if they have no match in the other tables, but it is the only outer join you want. You don't want to necessarily, for example, all rows in the table pmap represented. In this case, the join involving req should be an outer join, but all the other joins are inner joins.Here's a way to do it:
SELECT req.publication_paragraph_number AS publication_paragraph -- , req.description , req.frequency , CASE UPPER (req.frequency) WHEN 'DAILY' THEN 365 WHEN 'WEEKLY' THEN 52 WHEN 'MONTHLY' THEN 12 WHEN 'QUARTERLY' THEN 4 WHEN 'SEMIANNUALLY' THEN 2 WHEN 'ANNUALLY' THEN 1 ELSE 0 END AS num_req , lpm.equipment_ident , COUNT (fsep.fac_id) AS activities_performed FROM pm_requirements_table req LEFT OUTER JOIN ( lpm_paragraph_mapping_table pmap JOIN lpm ON TRIM (lpm.publication_paragraph) = pmap.paragraph_alias_mapping AND TRIM (lpm.publication_order) = '6310.19A' AND TRUNC (lpm.start_date, 'YEAR') = TO_DATE ('01/01/2010', 'MM/DD/YYYY') AND lpm.fac_ident = 'ATL' JOIN fsep ON fsep.fac_id = lpm.fac_ident AND fsep.facility = lpm.fac_type ) ON req.publication_order = pmap.publication_order AND req.publication_paragraph_number = pmap.publication_paragraph GROUP BY req.publication_paragraph_number, req.description, req.frequency, lpm.equipment_ident ORDER BY req.publication_paragraph_number ;
Only the FROM clause has changed since yesterday.
Output:` ACTIV PUBLICAT ITIES ION_PARA EQUIPMEN _PERF GRAPH FREQUENCY NUM_REQ T_IDENT ORMED -------- --------- ---------- -------- ----- 161A WEEKLY 52 CHAN A 5 161A WEEKLY 52 CHAN B 5 161B WEEKLY 52 CHAN A 5 161B WEEKLY 52 CHAN B 5 161C WEEKLY 52 CHAN A 5 161C WEEKLY 52 CHAN B 5 161D(1) WEEKLY 52 0 161D(2) WEEKLY 52 0 161D(3) WEEKLY 52 0 161D(4) WEEKLY 52 0 161D(5) WEEKLY 52 0 161D(6) WEEKLY 52 0 161E WEEKLY 52 0 161F WEEKLY 52 0 161G WEEKLY 52 0 161H WEEKLY 52 0 161I WEEKLY 52 0 161J WEEKLY 52 0 161K WEEKLY 52 0
-
Dear all,
I have a sql like query below
SELECT min (G.TRANSACTION_DATE), D.REQUEST_NUMBER
MTL_TXN_REQUEST_HEADERS D,.
MTL_TXN_REQUEST_LINES, E.
MTL_MATERIAL_TRANSACTIONS G,.
Mtl_Transaction_Types I have
WHERE D.HEADER_ID = E.HEADER_ID
AND G.TRANSACTION_TYPE_ID = I.TRANSACTION_TYPE_ID
AND Upper (I.Transaction_Type_Name) = Upper ('TEC outcome')
AND E.LINE_ID = G.MOVE_ORDER_LINE_ID
AND D.MOVE_ORDER_TYPE = 5
TO_DATE (G.TRANSACTION_DATE) BETWEEN TO_DATE('01-JAN-2014') AND TO_DATE('31-DEC-2014')
D.REQUEST_NUMBER GROUP
I need to get the first number of the application and finally ask for number based on the date of the transaction, how can I get the number of name application and based on the date of the transaction for the same query, please help me.
above query is back under results
If the query should return a line with the number of application like 2383 based on minimum transaction date and another column based on the maximum transaction date, please help me.
so in the example above, it must return
FIRST REQUEST NUMBER LAST NUMBER
2383 1886
Thank you
select min(request_number) keep(dense_rank first order by transaction_date asc ) request_number_min , min(request_number) keep(dense_rank first order by transaction_date desc) request_number_max from ( select min(g.transaction_date) transaction_date , d.request_number from mtl_txn_request_headers d , mtl_txn_request_lines e , mtl_material_transactions g , mtl_transaction_types i where d.header_id = e.header_id and g.transaction_type_id = i.transaction_type_id and upper(i.transaction_type_name) = upper('WIP Issue') and e.line_id = g.move_order_line_id and d.move_order_type = 5 and to_date(g.transaction_date) between to_date('01-jan-2014') and to_date('31-dec-2014') group by d.request_number )
-
Need help with the query (transpose)
Hello experts, please help here - 11 g Oracle, attribute APA APB are fixed values and can be hard coded in query
Need to transpose these data. Max(decode.. perd les données en sortie à cause de la condition de Max.)
Entry:
Name | Attribute | Value
A1 APP 10
A1 PDB 11
A1 APA 20
A1 PDB 21
A2 BPA 13
A2 BPB 14
Expected results:
Name AttVal1 AttVal2
A1 10 11
13 14 A2
20 21 A1
Hello
Here's one way:
WITH relevant_columns AS
(
SELECT name
value
CASE
WHEN the attribute ("APA", "BPA") THEN 1
WHEN the attribute ("PDB", "BPB") THEN 2
END AS c_num
ROW_NUMBER () (PARTITION BY NAME, attirbute
Value of ORDER BY
) AS r_num
FROM table_x
)
SELECT name, attval1, attval2
OF relevant_columns
PIVOT (MAX (value)
FOR c_num IN (1 AS attval1
2 UNDER attval2
)
)
ORDER BY r_num, name
;
If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.
Why do you want to
NAME ATTVAL1 ATTVAL2
---- ------- -------
A1 10 11
20 21 A1
in the results, rather than
NAME ATTVAL1 ATTVAL2
---- ------- -------
10 21 A1
20 11-A1
? You would be satisfied to one or the other?
Depending on your answer, you may need to modify the analytical ORDER BY clause in the ROW_NUMBER function.
-
Need help with a query complex for the production database
Hello again,
I need your help once again, for a query how to show me how long each stage of production is by order.
See examples of data and what I expect.
Thank you all for your help.
We use Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
Here the example data tables:
And here's what I expect of my request:CREATE TABLE TABLE_2 ( "ORDER_NR" VARCHAR2 (12) , "PRIORITY" VARCHAR2 (2) , "WO_STEP" VARCHAR2 (1) , "STEP_DATE" DATE ); CREATE TABLE TABLE_1 ( "ORDER_NR" VARCHAR2 (12) PRIMARY KEY , "PRIORITY" VARCHAR2 (2) , "CREATE_DATE" DATE , "ACT_STEP" VARCHAR2 (2) , "STEP_DATE" DATE , "EMPLOYEE" VARCHAR2 (5) , "DESCRIPTION" VARCHAR2 (20) ); INSERT INTO TABLE_1 (ORDER_NR, PRIORITY, CREATE_DATE, ACT_STEP, STEP_DATE, EMPLOYEE, DESCRIPTION) VALUES ('1KKA1T205634', '12', TO_DATE('10-FEB-13 10:00:00','DD-MON-RR HH24:MI:SS'), 'U', TO_DATE('28-FEB-13 12:00:00','DD-MON-RR HH24:MI:SS'), 'W0010', 'CLEAN HOUSE'); INSERT INTO TABLE_1 (ORDER_NR, PRIORITY, CREATE_DATE, ACT_STEP, STEP_DATE, EMPLOYEE, DESCRIPTION) VALUES ('1KKA1Z300612', '12', TO_DATE('08-FEB-13 14:00:00','DD-MON-RR HH24:MI:SS'), 'F', TO_DATE('20-FEB-13 16:00:00','DD-MON-RR HH24:MI:SS'), 'K0052', 'REPAIR CAR'); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1T205634', '12', 'A', TO_DATE('12-FEB-13 13:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1T205634', '12', '5', TO_DATE('13-FEB-13 09:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1T205634', '12', 'K', TO_DATE('13-FEB-13 10:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1T205634', '12', '5', TO_DATE('13-FEB-13 11:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1T205634', '12', 'K', TO_DATE('13-FEB-13 12:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1T205634', '12', '5', TO_DATE('13-FEB-13 16:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1T205634', '12', 'C', TO_DATE('14-FEB-13 08:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1T205634', '12', 'B', TO_DATE('14-FEB-13 10:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1T205634', '12', 'E', TO_DATE('18-FEB-13 13:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1T205634', '12', 'F', TO_DATE('20-FEB-13 16:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1T205634', '12', 'S', TO_DATE('21-FEB-13 08:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1T205634', '12', 'R', TO_DATE('21-FEB-13 09:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1T205634', '12', 'U', TO_DATE('28-FEB-13 12:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1Z300612', '12', 'A', TO_DATE('12-FEB-13 13:52:42','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1Z300612', '12', '5', TO_DATE('13-FEB-13 09:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1Z300612', '12', 'K', TO_DATE('13-FEB-13 10:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1Z300612', '12', '5', TO_DATE('13-FEB-13 11:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1Z300612', '12', 'K', TO_DATE('13-FEB-13 12:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1Z300612', '12', '5', TO_DATE('13-FEB-13 16:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1Z300612', '12', 'C', TO_DATE('14-FEB-13 08:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1Z300612', '12', 'B', TO_DATE('14-FEB-13 10:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1Z300612', '12', 'E', TO_DATE('18-FEB-13 13:00:00','DD-MON-RR HH24:MI:SS')); INSERT INTO TABLE_2 (ORDER_NR, PRIORITY, WO_STEP, STEP_DATE) VALUES ('1KKA1Z300612', '12', 'F', TO_DATE('20-FEB-13 16:00:00','DD-MON-RR HH24:MI:SS')); COMMIT;
And now the explanation for the result of the query:SYSDATE 28.Feb.13 14:00 ORDER_NR PRIORITYCREATE_DATE STATUS STATUS_DATE DESCRIPTION AGE_1 AGE_2 WAITNG STEP_A STEP_B STEP_C STEP_5 STEP_K STEP_E STEP_F STEP_S STEP_R 1KKA1T205634 12 10.Feb.13 10:00 U 28.Feb.13 12:00 CLEAN HOUSE 18,083 8,833 2,125 0,833 4,125 0,083 0,750 0,208 2,125 0,666 0,042 7,125 1KKA1Z300612 12 08.Feb.13 14:00 F 20.Feb.13 16:00 REPAIR CAR 20,000 16,042 2,125 0,833 4,125 0,083 0,750 0,208 2,125 0,666
The AGE_1 is the difference in days between the "CREATE_DATE" and if EXSIST L'ETAPE 'U' then STEP_DATE or if the STEP 'U' is not found in TABLE_2 then it should show the difference in days between the "CREATE_DATE' and the 'SYSDATE.
The AGE_2 is the difference in days between the STEP "A" STEP_DATE and IF EXSIST L'ETAPE 'R' then STEP_DATE or if the STEP 'R' is not in TABLE_2 then it should show the difference in days between the "CREATE_DATE' and the 'SYSDATE.
The EXPECTATION is the difference in days between CREATE_DATE and STEP 'A' STEP_DATE
The following columns indicate the days, how long the ORDER_NR remains in these TIMES, if an ORDER_NR comes in the same STEP should be calculated together more than once.
If the ORDER_NR jump a step, it should show a zero in the specific field.
I hope that my explanation is good enough, my English skills are far from good.
Thank you for all your help.
Hosts Reinhard W.Solomon Yakobson says:
Just add the amounts:In fact, you could edit all CASES:
with t2 as ( select t.*, lead(step_date) over(partition by order_nr order by step_date) next_step_date from table_2 t ) select t1.*, nvl( max( case t2.wo_step when 'U' then t2.step_date end ), sysdate ) - t1.create_date age_1, nvl( max( case t2.wo_step when 'R' then t2.step_date end ), sysdate ) - t1.create_date age_2, sum( case when t2.wo_step in ('B','5') then t2.next_step_date - t2.step_date end ) step_b_5, sum( case t2.wo_step when 'C' then t2.next_step_date - t2.step_date end ) step_c, sum( case t2.wo_step when 'K' then t2.next_step_date - t2.step_date end ) step_k, sum( case t2.wo_step when 'E' then t2.next_step_date - t2.step_date end ) step_e, sum( case t2.wo_step when 'F' then t2.next_step_date - t2.step_date end ) step_f, sum( case t2.wo_step when 'S' then t2.next_step_date - t2.step_date end ) step_s, sum( case t2.wo_step when 'R' then t2.next_step_date - t2.step_date end ) step_r from table_1 t1, t2 where t2.order_nr = t1.order_nr group by t1.order_nr, t1.priority, t1.create_date, t1.act_step, t1.step_date, t1.employee, t1.description / ORDER_NR PR CREATE_DA AC STEP_DATE EMPLO DESCRIPTION AGE_1 AGE_2 STEP_B_5 STEP_C STEP_K STEP_E STEP_F STEP_S STEP_R ------------ -- --------- -- --------- ----- ----------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- 1KKA1T205634 12 10-FEB-13 U 28-FEB-13 W0010 CLEAN HOUSE 18.0833333 10.9583333 4.875 .083333333 .208333333 2.125 .666666667 .041666667 7.125 1KKA1Z300612 12 08-FEB-13 F 20-FEB-13 K0052 REPAIR CAR 44.252338 44.252338 4.875 .083333333 .208333333 2.125 SQL>
SY.
-
NEED HELP WITH THE QUERY, NEED MORE RECENT FILE ONLY
Hi all
That is,
I have an assignment I need to find agents that allow players to break the rules.
So far, I have 41 results, in which there are 4 principles and 24 footballers and football player even beat more than one rule or the rule more than once.
What I need now is to make arrangements so that every footballer appears once n matter how many times they have broken the rules.
I have
SELECT
t.transfer_time | ' ' || a.first_name | ' ' || a.last_name | ' ' || f.first_name | ' ' || f.last_name | ' ' || f.footballer_id | ' ' || t.transfer_id
Of
agents a, t transfers, footballers f, footballers_fees fo
WHERE
a.agent_id = t.broker_id
AND
t.footballer_id = f.footballer_id
AND
f.footballer_id = fo.footballer_id
AND
(RULE 1 BROKEN AND RULE 2 BROKEN
OR
RULE 1 BROKEN AND ARTICLE 2 DOES NOT DECOMPOSE
OR
RULE 1 DOES NOT DECOMPOSE AND RULE 2 BROKEN)
GROUP BY
t.transfer_time | ' ' || a.first_name | ' ' || a.last_name | ' ' || f.first_name | ' ' || f.last_name | ' ' || f.footballer_id | ' ' || t.transfer_id
ORDER BY
t.transfer_time | ' ' || a.first_name | ' ' || a.last_name | ' ' || f.first_name | ' ' || f.last_name | ' ' || f.footballer_id | ' ' || t.transfer_id
;
(I did not type the SQL code to rules 1 and 2 but I know it works)
Now, I need not to show that every footballer once they broke rule and more than once or not.
I was looking at the screen nearly enough hours 10 and any help or ideas would be greatly appreciated
Thank you all :)Hello
Welcome to the forum!
Whenever you have a problem, please post a small example of data (CREATE TABLE and INSERT statements) so that people who want to help you can recreate the problem and test their ideas. You don't have to display a large amount of data. In this case, it seems that 2 to 10 lines for each table could give a good picture of the problem.
After the results that you want samples fropm, and explain how you get those resulting from these data.
Always tell what version of Oracle you are using.The ideal outcome would be just what you '; Re I get now, but with some deleted rows and only 1 line by left footballer? If so, do a subquery on the original query, and then add somehting like
, ROW_NUMBER () OVER (PARTITION BY f.footballer_id ORDER BY NULL) AS r_num
in the SELECT clause.
then, in the main query, display only linesWHERE r_num = 1
ROW_NUMBER requires an ORDER byclause of analytics. If you ORDER BY a constant (e.g. NULL) then what line gets number 1 will be arbitrary. If you care who lines for a given player is numbered 1 (and therefore included in the final output), then adjust the analytical ORDER BY clause. (You the title mentions "most recent record only", so if the dt column indicates whether a line is "newer" than another, you can "ORDER BY dt DESC".)
I know this response is vague in places. Without a concrete example (CREATE TABLE and instructions INSERT for examples of data and outcomes from these data), that's the best I can do.
-
Need help with the query using the AVG function
First post here.
I am a student taking a SQL class and I can't find a query.
I think I'm close to get it, but I can not quite all the way there.
Three tables are involved in this problem. Here is a list of the tables and the areas concerned:
Problem:orders table: order# shipstate orderitems table: order# isbn quantity (How many copies of book purchased on that order) books table: isbn retail (retail price of book)
I want to get an average of "total amount" by shipstate.
For example, in these tables, there are 8 records of the State of Florida.
However, there are only 5 unique order # for this State.
The amount of detail * quantity for these 8 disks (or 5 orders) is $345,10
Now to get my average $345,10 should be divided by 5. (number of unique commands)
In the following query it divides this $345,10 8. (number of records)
How to make this request to divide by the number of unique order # rather than the number of records?
According to me, once I get this part down, I can understand the rest of the problem.SELECT shipstate, AVG(quantity * retail) FROM orders JOIN orderitems USING (order#) JOIN books USING (isbn) GROUP BY shipstate HAVING SUM(quantity * retail) =ANY (SELECT SUM(quantity * retail) FROM books JOIN orderitems USING (isbn) JOIN orders USING (order#) GROUP BY shipstate)
The end result, I need, is to find all the individual commands that have a "total amount due" that is greater than the 'average amount due' for this state of clients.
Any help, suggestions or comments welcome.
MattYour average take into account the shipstate (8 disks), you can do that for the expected results.
With some examples of input data it would be easier, but here a try:SELECT shipstate, sum(quantity * retail)/count(distinct order#) FROM orders JOIN orderitems USING (order#) JOIN books USING (isbn) GROUP BY shipstate;
Nicolas.
delete the alias
Edited by: N. Gasparotto on October 3, 2008 19:28 -
Need help with sql query performance
Dear all,
I have a sql like query below, I need to give the following query please help me identify which statement I should tune to have better performanece.
Select rownum LINE_NUM,
A.LINE_ID,
TO_CHAR (A.INVITMID),
TO_NUMBER (A.PICKQTY),
UNLOADINGPNT NULL,
RRNUM NULL,
WORKORDNUM NULL,
WORKORDDESC NULL,
A.PONUM,
DTR_DUMB NULL,
A.DESCRIPTION,
FROM_SUB NULL,
TO_SUB NULL,
NO SOURCE,
ASSET_NUMBER NULL,
A.RECEIPTNUM,
MOVEORD NULL,
FROM_LOC NULL,
TO_LOC NULL,
MSD_NUM NULL,
CONTAIN_LINE NULL,
A.UOM,
A.PO_RELEASE
de)
Select headerid Po.Po_Header_Id,
rcv1. Po_Line_Id LINE_ID,
rcv1.item_id INVITMID,
(NVL(Rcv1.Transact_Qty,0)-NVL(rcv2.transact_qty,0)) PICKQTY,
Po.Segment1 PONUM,
Rcv1.Receipt_Num RECEIPTNUM,
Rcv1.Item_Desc DESCRIPTION,
Rcv1.Transact_Uom GLU,
Rcv1.Po_release
Po_Headers_All in.,.
(Select rcv3. Po_Header_Id, RCV3.receipt_num, rcv3. Po_Line_Id, rcv3. Destination_Type_Code, rcv3. Item_Id, rcv3. Item_Desc, rcv3. Transact_Uom, SUM (rcv3. Transact_Qty) Transact_Qty, rcv3. PO_RELEASE OF)
SELECT A.Po_Header_Id,
C.RECEIPT_NUM receipt_num,
A.Po_Line_Id,
A.Destination_Type_Code,
B.Item_Id,
B.item_description Item_Desc,
A.UNIT_OF_MEASURE Transact_Uom,
A.QUANTITY Transact_Qty,
D.RELEASE_NUM PO_RELEASE
OF RCV_TRANSACTIONS,.
RCV_SHIPMENT_HEADERS C.
B RCV_SHIPMENT_LINES,
PO_RELEASES_ALL D
WHERE C.SHIPMENT_HEADER_ID = A.SHIPMENT_HEADER_ID
AND B.SHIPMENT_LINE_ID = A.SHIPMENT_LINE_ID
AND UPPER (A.Transaction_Type) = "to DELIVER".
AND higher (A.Destination_Type_Code) = "EXPENSES".
AND D.PO_RELEASE_ID = A.PO_RELEASE_ID
UNION ALL
SELECT A.Po_Header_Id,
C.RECEIPT_NUM receipt_num,
A.Po_Line_Id,
A.Destination_Type_Code,
B.Item_Id,
B.item_description Item_Desc,
A.UNIT_OF_MEASURE Transact_Uom,
A.QUANTITY Transact_Qty,
D.RELEASE_NUM PO_RELEASE
OF RCV_TRANSACTIONS,.
RCV_SHIPMENT_HEADERS C.
B RCV_SHIPMENT_LINES,
PO_RELEASES_ALL D
WHERE C.SHIPMENT_HEADER_ID = A.SHIPMENT_HEADER_ID
AND B.SHIPMENT_LINE_ID = A.SHIPMENT_LINE_ID
AND B.ITEM_ID IS NULL
AND UPPER (A.Transaction_Type) = "to DELIVER".
AND higher (A.Destination_Type_Code) = "WORKSHOP".
D.PO_RELEASE_ID AND = A.PO_RELEASE_ID) rcv3
GROUP BY rcv3. Po_Header_Id, RCV3.receipt_num, rcv3. Po_Line_Id, rcv3. Destination_Type_Code, rcv3. Item_Id, rcv3. Item_Desc, rcv3. Transact_Uom, rcv3. Rcv1 PO_RELEASE),
(SELECT A.PO_LINE_ID,
Sum (A.Quantity) transact_qty,
A.PO_HEADER_ID,
C.RECEIPT_NUM
OF RCV_TRANSACTIONS,.
RCV_SHIPMENT_HEADERS C.
B RCV_SHIPMENT_LINES,
PO_RELEASES_ALL D
WHERE C.SHIPMENT_HEADER_ID = A.SHIPMENT_HEADER_ID
AND B.SHIPMENT_LINE_ID = A.SHIPMENT_LINE_ID
AND UPPER (A.Transaction_Type) = "RETURN to the RECEPTION"
AND D.PO_RELEASE_ID = A.PO_RELEASE_ID
A.PO_LINE_ID, A.PO_HEADER_ID, C.RECEIPT_NUM GROUP) Rcv2
Where Po.Po_Header_Id = Rcv1.Po_Header_Id (+)
And Rcv1.Po_Line_Id = Rcv2.Po_Line_Id (+)
And Rcv1.Receipt_Num = Rcv2.Receipt_Num (+)
And Rcv1.Transact_Qty <>Nvl(Rcv2.Transact_Qty,999999999)
Group of po.po_header_id, rcv1.po_line_id, po.segment1, rcv1.receipt_num, rcv1.item_id, Rcv1.Item_Desc, rcv1. TRANSACT_UOM, rcv1. PO_RELEASE, (NVL(Rcv1.Transact_Qty,0)-NVL(RCV2.transact_qty,0))) has
Is my version of the database: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
Please find the attached PLAN to EXPLAIN.
Thank you
May be essentially the same join (between a, b, c and d) twice instead of three times
sounds like it could be done with a single join (between a, b, c, and d), but you do not some columns than the columns of rcv1 rcv2
We can work on what we can see only
Select rownum line_num,
rcv1.po_line_id line_id,
TO_CHAR (rcv1.item_id) invitmid,
NVL(rcv1.transact_qty,0) - nvl(rcv2.transact_qty,0) pickqty,
unloadingpnt null,
rrnum null,
workordnum null,
workorddesc null,
Po. Ponum Segment1,
dtr_dumb null,
description of the rcv1.item_desc,
from_sub null,
to_sub null,
No source,
asset_number null,
rcv1.receipt_num receiptnum,
moveord null,
from_loc null,
to_loc null,
msd_num null,
contain_line null,
Glu rcv1.transact_uom,
rcv1.po_release
of po_headers_all in.
left outer join
(select a.po_header_id,
c.receipt_num,
a.po_line_id,
a.destination_type_code,
b.item_id,
b.item_description item_desc,
a.unit_of_measure transact_uom,
Sum (a.Quantity) transact_qty,
d.release_num po_release
from (select shipment_header_id,
shipment_line_id,
po_release_id,
po_header_id,
po_line_id,
destination_type_code,
unit_of_measure,
quantity
of rcv_transactions
where upper (a.transaction_type) = "to DELIVER".
and upper (a.destination_type_code) ('charge', 'WORKSHOP')
) a
inner join
rcv_shipment_lines b
On a.shipment_line_id = b.shipment_line_id
inner join
c rcv_shipment_headers
On a.shipment_header_id = c.shipment_header_id
left outer join
po_releases_all d
On a.po_release_id = d.po_release_id
where upper (a.destination_type_code) = "EXPENSES".
or (upper (a.destination_type_code) = 'WORKSHOP'
and b.item_id is null
)
A.po_header_id group,
c.receipt_num,
a.po_line_id,
a.destination_type_code,
b.item_id,
b.item_description,
a.unit_of_measure,
d.release_num
) rcv1
On po.po_header_id = rcv1.po_header_id
left outer join
(select a.po_line_id,
Sum (a.Quantity) transact_qty,
a.po_header_id,
c.receipt_num
from (select shipment_header_id,
shipment_line_id,
po_release_id,
po_header_id,
quantity
of rcv_transactions
where upper (a.transaction_type) = "RETURN to THE RECIPIENTS.
) a
inner join
rcv_shipment_lines b
On a.shipment_line_id = b.shipment_line_id
inner join
c rcv_shipment_headers
On a.shipment_header_id = c.shipment_header_id
left outer join
po_releases_all d
On a.po_release_id = d.po_release_id
A.po_line_id group,
a.po_header_id,
c.receipt_num
) rcv2
On rcv1.po_line_id = rcv2.po_line_id
and rcv1.receipt_num = rcv2.receipt_num
where rcv1.transact_qty! = nvl(rcv2.transact_qty,999999999)
Concerning
Etbin
-
Need help with a query of type "connect by level.
Hello, I recently met 'connect by level' and I think he can solve my problem, but maybe not. I would like to create rows of data where the number of rows created varies according to the data from the original table.
It works:
with times like
(select to_date (' 26/01/2014 01:00 ',' dd/mm/yyyy hh24:mi:ss') starttime,)
TO_DATE (' 27/01/2014 00:00:00 ',' dd/mm/yyyy hh24:mi:ss') stoptime
the double)
Select starttime, stoptime, starttime + rownum / 24
of the time
connect by level < =.
(Select trunc ((stoptime-starttime) * 24: 2) at the time)
I would like to do something similar for several lines (following does not work)
with times like
(select to_date (' 26/01/2014 01:00 ',' dd/mm/yyyy hh24:mi:ss') starttime,)
TO_DATE (' 27/01/2014 00:00:00 ',' dd/mm/yyyy hh24:mi:ss') stoptime
of the double
Union
Select to_date (' 25/01/2014 18:00 ',' dd/mm/yyyy hh24:mi:ss') starttime.
TO_DATE (' 27/01/2014 00:00:00 ',' dd/mm/yyyy hh24:mi:ss') stoptime
the double)
Select starttime, stoptime, starttime + rownum / 24
of the time
connect by level < =.
(Select trunc ((stoptime-starttime) * 24: 2) at the time)
I need to stay away from solutions of PL/SQL, this query will be wrapped in an application that can not handle the PL/SQL, going and coming from the database (I also suck in PL/SQL).
Any help would be greatly appreciated, I have no knowledge here, I tried to read some of the documentation on hierarchical queries, but it is not yet clicking.
Thank you!
Or also:
SQL > WITH times
2 ALSO (SELECT TO_DATE (' 01:00 26/01/2014 ', "hh24:mi:ss dd/mm/yyyy") Starttime)
3, TO_DATE (' 01/26/2014 03:00 ', 'hh24:mi:ss dd/mm/yyyy') Stoptime
4 FROM TWO
5 UNION
6 SELECT TO_DATE (' 25/01/2014 18:00 ', "hh24:mi:ss mm/dd/yyyy") Starttime
7, TO_DATE (' 25/01/2014 22:00 ', 'hh24:mi:ss dd/mm/yyyy') Stoptime
8 DOUBLE)
9. SELECT T.*, Starttime + Lvl / 24
10. OF time T
11, (SELECT LEVEL Lvl
THE DOUBLE 12
13 CONNECT BY LEVEL<>
14 (SELECT MAX (TRUNC ((Stoptime-Starttime) * 24)))
15 AT the time)):
16. WHERE the lvl<= trunc="" (="" (stoptime="" -="" starttime)="" *="">=>
17 ORDER 1, 3
18.
STARTTIME STOPTIME-STARTTIME + LVL/24
----------------------------- ----------------------------- -----------------------------
January 25, 2014 18:00 January 25, 2014 22:00 January 25, 2014 19:00
January 25, 2014 18:00 January 25, 2014 22:00 January 25, 2014 20:00
January 25, 2014 18:00 January 25, 2014 22:00 January 25, 2014 21:00
January 25, 2014 18:00 January 25, 2014 22:00 January 25, 2014 22:00
26 January 2014 01:00 26 January 2014 03:00 January 26, 2014 02:00
26 January 2014 01:00 26 January 2014 03:00 January 26, 2014 03:00
6 selected lines.
-
Need help with a query complex
ID Col1 Col2 COL3 COL4 VAL 1 col1_1 col2_1 col3_1 col4_1 val1 1 col1_1 col2_1 col3_1 * val2 1 col1_1 col2_1 * * val3 1 col1_1 * * * Val4 1 * * * * Val5 I want to get the result.
Col1, col2, col3, col4 will be entered and I need to find the Val by matching the Col1, col2, col3 col4.
IF there is no match for any column, then it should consider it as *.
So basically for any value of Col1, col2, col3, col4, it should return Val.
Example - he must return val1 for col1_1, col2_1, col3_1, col4_1
and val5 for col1_11, col2_11, col3_11 and col4_11 have no match for all 4 columns here.
How to write a simplified in this case request? any help is really appreciated.
SQL > with t as)
2. Select val,
3 dense_rank() on)
4 order of col1 case when ' *' then 0 end of another 1 +.
5 case col2 where ' *' then 0 end of another 1 +.
6 case col3 where ' *' then 0 end of another 1 +.
7 case col4 when ' *' 0 then 1 other side desc
8 ) rnk
9 of tbl
10 where col1 in ('col1_1','* ')
11 and col2 in ('col2_1','* ')
12 and col3 in ('col3_1','* ')
13 and col4 in ('col4_1','* ')
14 )
15 select val
16 t
where the 17 rnk = 1
18.VAL
----
val1SQL > with t as)
2. Select val,
3 dense_rank() on)
4 order of col1 case when ' *' then 0 end of another 1 +.
5 case col2 where ' *' then 0 end of another 1 +.
6 case col3 where ' *' then 0 end of another 1 +.
7 case col4 when ' *' 0 then 1 other side desc
8 ) rnk
9 of tbl
10 where col1 in ('col1_11','* ')
11 and col2 in ('col2_11','* ')
12 and col3 in ('col3_11','* ')
13 and col4 in ('col4_11','* ')
14 )
15 select val
16 t
where the 17 rnk = 1
18.VAL
----
Val5SQL >
SY.
-
need help with the query: (Frank)
Hi Frank,.
I have the oracle 8 database.
I have the following table with the data structure:
TABLE P (PID, PNAME, COLOR)
PRIMARY KEY: PID
CAT TABLE (SID, PID, COST)PID Pname Color p1........... Red P2................. green p3............... blue p4 .................. red
KEY: SID MAIN + PID
KEY REFERENCE: SID REFERENCE S.SID
PID P.PID REFERENCES
now my question is:Sid Pid COst.... S1 P1 S2 P2 S3 P3 S1 P4 S2 p1 S3 p1
I want to find the SIDS of suppliers that provide a red and a green part
for this I used the following query, but it gives the result worng...
can help me please in this way to get this...
select sid from cat where pid in (select pid from p where color= 'red' union select pid from p where color = 'gren') group by sid having count(pid) >= 2
Hello
Jojo wrote:
Hi Frank,.It would be nice if someone with a different name helped you? Do not restrict yourself by addressing someone in particular in your subject line or the first message.
I have the oracle 8 database.
I have the following table with the data structure:TABLE P (PID, PNAME, COLOR)
PRIMARY KEY: PIDPID Pname Color p1........... Red P2................. green p3............... blue p4 .................. red
CAT TABLE (SID, PID, COST)
KEY: SID MAIN + PID
KEY REFERENCE: SID REFERENCE S.SID
PID P.PID REFERENCESSid Pid COst.... S1 P1 S2 P2 S3 P3 S1 P4 S2 p1 S3 p1
now my question is:
I want to find the SIDS of suppliers that provide a red and a green partfor this I used the following query, but it gives the result worng...
can help me please in this way to get this...
select sid from cat where pid in (select pid from p where color= 'red' union select pid from p where color = 'gren') group by sid having count(pid) >= 2
You don't like what is the number of lines with a pid; If you had 20 rows all said 'p1', that would be good enough. The number of distinct colors of the whole ('red', 'green') is what is important.
Avoid the UNION when there is a simple alternative. The UNION tends to be slow.You can use a join instead, like this:
SELECT c.sid FROM cat c , p WHERE p.pid = c.pid AND p.color IN ('red', 'green') GROUP BY c.sid HAVING COUNT (DISTINCT p.color) = 2 ;
If you would care to post CREATE TABLE and INSERT statements for the sample data and the results that you want from this data, then I could test this.
Published by: Frank Kulash, January 10, 2011 15:25
-
Need help with the query to get the County
Hello
Oracle 10 g 2 10.2.0.3 - 64 bit
I want back the number of accounts with two different types of funds (say A and B). Some accounts hold only one of the two funds, and some support both. I want to get the counts like this:
- account held funds - has only
- accounts holding funds-B only
- accounts holding the Fund-A and B funds
Here is what I started with but need assistance to meet the requirement above:
select count(distinct acct.bkoff_acct_no ) accounts_holding_fund_A from xe_account acct, xec_tal_investment_mandate iman, xec_tal_asset_allocation alloc, xe_benchmark bmark, xe_benchmark_usage bu, xe_object_description xod, xec_asset_class cls where iman.mandate_status_cd='A' and cls.asset_class_cd = alloc.asset_class_cd and iman.mandate_id = alloc.mandate_id and acct.account_id = iman.object_id and iman.object_type_cd = 'ACCT' and iman.mandate_id = xod.object_id and xod.field_nm='XEC_TAL_INVESTMENT_MANDATE.COMMENT_TXT' and xod.language_cd = 'E' and acct.acct_status_cd = 'O' and bu.object_type_cd(+) = 'TMAA' and bu.object_id(+) = alloc.asset_allocation_id and bmark.benchmark_id(+) = bu.benchmark_id and alloc.resp_txt like '%fund-A%'
And suppose that the Fund-B has resp_txt like ' % of Fund-B»
Please suggest.
Concerning
Hello
Here is another way, it is easier to adapt to different jobs and different numbers of jobs:
WITH got_distinct_jobs AS
(
SELECT DISTINCT deptno, job
FROM scott.emp
WHERE job IN ("ANALYST", "CLERKS") - or what
)
got_job_list AS
(
SELECT LISTAGG (job, ",") THE Group (ORDER BY work) AS job_list
OF got_distinct_jobs
GROUP BY deptno
)
SELECT job_list
COUNT (*) AS num_departments
OF got_job_list
GROUP BY job_list
;
This shows all the combinations of the jobs listed in the WHERE clause of got_distinct_jobs. You don't need to change anything else in the query. There may be any number of jobs.
Output:
JOB_LIST NUM_DEPARTMENTS
------------------------------ ---------------
CLERK 2
ANALYST, CLERK 1
Maybe you are looking for
-
Key records is not on Satellite C660
The keyboard on my month Satellite C660 often doesn't seem to work properly 100% - lack of characters, double and generally does not record the capital letter when you use the SHIFT key (shows apital rather than Capital). It is intermittent then mayb
-
OfficeJet Pro 8210: network capabilities are not available.
Hi, I have been setting up the printer above but I need to put in place on a network. I don't have the network option as it says "network capabilities are not available. When I print the network configuration page, it says network capacities have bee
-
Need help with a Citadel of DIAdem data store opening.
Hello I was wondering if someone can help me to connect to a Citadel of DIAdem data store. I've read all the online help and cannot operate. On my PC, I use DIAdem v11.1 and v6.1 Lookout installed as a plugin. I am trying to connect to a data of Cita
-
7741Z lan Broadcom driver. No driver installation
Don't Aspire 7741z-4643 Broadcom driver has no Setuip file Win 7 64
-
I have an AT & T DSL network with a Wi - Fi connection in the House...