Retrieve n and n-1 rows on the same line
In a database I am trying to get the latest employee information and the previous entry. The latest entry can be determined by the fact that DATEFIN is empty and the previous entry is returned by MAX(DATEFIN). All previous entries have a DATEFIN value
So I wrote a query which returned both the lines per employee. i.e. n and n-1
Actually what is needed is to compare certain fields of each line, so I need to show employee n and n-1 on the same line. This time I used LEAD so emp,date,field1,Lead(field1,1) etc etc.
As all the employee lines are returned, I used a minus function to remove all those where the DATEFIN IS NOT NULL, given that the LEAD line returned the information required BEFORE the minus removed it.
However, I am still getting n and n-1 rows, even though the minus part run by itself removes n-1,n-2... rows.
Question
How can I structure the minus or LEAD query just to get the n row and n-1 LEAD information
select trim(to_char(se.idexport,'0999'))
|| '|'
|| sa.referentiel_id
|| '|'
|| sa.idunique
|| '|'
|| sa.matricule
|| '|'
|| sr.niveau
|| '|'
|| LEAD(sr.niveau,1) OVER (ORDER BY sr.salarie_id,sr.datedebut desc )
|| '|'
|| sr.echelon
|| '|'
|| sr.coefficient
|| '|'
|| fo.code
|| '|'
|| sr.salairemensuel
|| '|'
|| sr.tauxhoraire
|| '|'
|| to_CHAR(ca.datevaleurrevisions,'DD/MM/YYYY')
|| '|'
|| em.code
|| '|'
|| fi.code
|| '|'
|| cc.code
|| '|'
|| sr.datedebut
|| '|'
|| LEAD(sr.datedebut,1) OVER (ORDER BY sr.salarie_id,sr.datedebut desc )
|| '|'
|| sr.datefin
|| '|'
|| LEAD(sr.datefin,1) OVER (ORDER BY sr.salarie_id,sr.datedebut desc )
AS Text
from salarie sa
inner join selection_export se on (se.IDUNIQUE = SA.IDUNIQUE AND se.idexport = 42 AND se.exporter = 1)
inner join salarierevision sr on (SR.SALARIE_ID = se.IDUNIQUE AND SR.ACCESRESTREINT = 0)
inner join campagne ca on CA.ISANNEEENCOURS = 1
inner join parambranche pb on (ca.organisationlds_id = pb.organisationlds_id)
inner join utilisateur u on (u.CODE = 'gagross' AND U.ORGANISATIONLDS_ID = CA.ORGANISATIONLDS_ID)
left outer join fonction fo on (fo.id = sr.fonction_id)
left outer join emploi em on (em.id = sr.emploi_id)
left outer join filiere fi on (fi.id = sr.filiere_id)
left outer join CONVENTIONCOLLECTIVE cc on (cc.id = sr.CONVENTIONCOLLECTIVE_ID)
minus
select trim(to_char(se.idexport,'0999'))
|| '|'
|| sa.referentiel_id
|| '|'
|| sa.idunique
|| '|'
|| sa.matricule
|| '|'
|| sr.niveau
|| '|'
|| LEAD(sr.niveau,1) OVER (ORDER BY sr.salarie_id,sr.datedebut desc )
|| '|'
|| sr.echelon
|| '|'
|| sr.coefficient
|| '|'
|| fo.code
|| '|'
|| sr.salairemensuel
|| '|'
|| sr.tauxhoraire
|| '|'
|| to_CHAR(ca.datevaleurrevisions,'DD/MM/YYYY')
|| '|'
|| em.code
|| '|'
|| fi.code
|| '|'
|| cc.code
|| '|'
|| sr.datedebut
|| '|'
|| LEAD(sr.datedebut,1) OVER (ORDER BY sr.salarie_id,sr.datedebut desc )
|| '|'
|| sr.datefin
|| '|'
|| LEAD(sr.datefin,1) OVER (ORDER BY sr.salarie_id,sr.datedebut desc )
AS Text
from salarie sa
inner join selection_export se on (se.IDUNIQUE = SA.IDUNIQUE AND se.idexport = 42 AND se.exporter = 1)
inner join salarierevision sr on (SR.SALARIE_ID = se.IDUNIQUE AND SR.ACCESRESTREINT = 0)
inner join campagne ca on CA.ISANNEEENCOURS = 1
inner join parambranche pb on (ca.organisationlds_id = pb.organisationlds_id)
inner join utilisateur u on (u.CODE = 'gagross' AND U.ORGANISATIONLDS_ID = CA.ORGANISATIONLDS_ID)
left outer join fonction fo on (fo.id = sr.fonction_id)
left outer join emploi em on (em.id = sr.emploi_id)
left outer join filiere fi on (fi.id = sr.filiere_id)
left outer join CONVENTIONCOLLECTIVE cc on (cc.id = sr.CONVENTIONCOLLECTIVE_ID)
where sr.datefin is not null
Thanks and I hope this is clear
Colin
Assuming that the sr.salarie_id column identifies the employee I think you need to partition by it, not order by it in the analytic functio. If it does not identify the employee, then you need to partition by whatever uniquely identifies an employee. I would likely structure it something like this:
SQL> with t as (
2 SELECT 1 emp_id, TO_DATE('01-jul-2010', 'dd-mon-yyyy') dt, 'Jul' descr
3 from dual union all
4 SELECT 1, TO_DATE('01-aug-2010', 'dd-mon-yyyy'), 'Aug' from dual union all
5 SELECT 1, TO_DATE('01-sep-2010', 'dd-mon-yyyy'), 'Sep' from dual union all
6 SELECT 1, TO_DATE('01-oct-2010', 'dd-mon-yyyy'), 'Oct' from dual union all
7 SELECT 1, TO_DATE(NULL), 'Current' from dual union all
8 SELECT 2, TO_DATE('01-jan-2010', 'dd-mon-yyyy'), 'Jan' from dual union all
9 SELECT 2, TO_DATE('01-mar-2010', 'dd-mon-yyyy'), 'Mar' from dual union all
10 SELECT 2, TO_DATE('01-may-2010', 'dd-mon-yyyy'), 'May' from dual union all
11 SELECT 2, TO_DATE('01-jul-2010', 'dd-mon-yyyy'), 'Jul' from dual union all
12 SELECT 2, TO_DATE(NULL), 'Current' from dual)
13 SELECT emp_id, curr_dt, last_dt, curr_descr, last_descr
14 FROM (SELECT emp_id, dt curr_dt,
15 LEAD(dt) OVER(PARTITION BY emp_id
16 ORDER BY dt desc nulls first) last_dt,
17 descr curr_descr,
18 LEAD(descr) OVER(PARTITION BY emp_id
19 ORDER BY dt desc nulls first) last_descr
20 FROM t)
21 WHERE curr_dt IS NULL
EMP_ID CURR_DT LAST_DT CURR_DE LAST_DE
1 01-OCT-2010 Current Oct
2 01-JUL-2010 Current JulWhere my t is your set of joined tables without the where sr.datefin is not null predicate.
John
Similar Messages
-
Report Template Help - Vertical report with multiple rows on the same line.
I am tearing my hair out trying to figure a way to do this. I want a vertical report, but with the rows across the page rather than down it.
e.g.
ROW1 ROW2 ROW3 ROW4 ROW5
ROW1 ROW2 ROW3 ROW4 ROW5
ROW1 ROW2 ROW3 ROW4 ROW5
ROW1 ROW2 ROW3 ROW4 ROW5
ROW1 ROW2 ROW3 ROW4 ROW5
ROW1 ROW2 ROW3 ROW4 ROW5
ROW1 ROW2 ROW3 ROW4 ROW5
ROW1 ROW2 ROW3 ROW4 ROW5Has anyone managed to do this?Use a custom named column report template. The template could generate either:
<li> a table with one physical <tt>tr</tt> row, with your "columns" being the logical "rows" of the report rendered as the <tt>td</tt>s within the row
<li> a list of lists using CSS to render them side-by-side via <tt>float</tt> or <tt>inline-block</tt> (Some examples of similar techniques) -
Why yahoo/gmail retrieval and facebook app so so slow when in WIFI. But using the internet to check for emails and facebook is fast using the same WIFI connection??
Hi SandyS_VZW,
Yes tried resetting the wifi connection and problem still persist.
Here it is...to make it clear. Connected thru the same wifi at home...
-> emails (yahoo/gmail) and facebook WEBSITES are working fine and fast when using/accessing thru a browser (chrome/samsung browser) - no problem with this.
-> emails (yahoo/gmail) and facebook APP is soooooo sloooww (thru the App). Slow I mean comparing it to using their browser/websites... news feeds/emails refreshing so quickly but not when using the APP installed in Samsung Galaxy Note 4. Slow like - It will take around 5-10minutes just to get your emails and news feed refreshed.
THIS HAPPENS ONLY WHEN CONNECTED THRU A WIFI which has a speed of 10-20mb. It is not happening when connected to the network data/plan.
My wife has the same Samsung Galaxy Note 4 (coming from different provider at&t) - same setup (emails, fb app), same wifi connection, but she's not experiencing anything like it.
Not sure why, I dont want to believe that while connected to a WIFI, Verizon is restricting anything and ******* me off to make me switch to my data plan connection everytime - which is Unfair!
Was there a known issue similar about this case?
thanks, -
I use "element 12" and want like in the old PS version due Automating and Contact II upload multiple filesand print them with any columns and rows on the same page . How does it work?
Can you supply a link?
-
How to Drag and Drop mutliple rows in the jtable
hai
i am having a jtree ,in which i added many nodes,each nodes hav
corresponding jtable with values. now i need to drag a group of rows from a jtable of particular node in jtree to another node.
at the same time i am possible to drag and drop the single row in the same sceanrio which i mentioned above.
how to do this,can anyone pls help me regarding this
gouthamThe Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html]How to Use Drag and Drop has an example with JTable support.
-
Get the rows in the same order in which it has been inserted.
Hi,
I have a table with four columns(All varchars)...and there are no primary keys
i have inserted 15 rows where col1="xyz"
Now while retrieving the same...i dont get the same in the order i ahve inserted..
What is the way to get the rows in the same order in which it has been inserted..?
RegardsI have a table with four columns(All varchars)...and
there are no primary keys
i have inserted 15 rows where col1="xyz"
Now while retrieving the same...i dont get the same
in the order i ahve inserted..
What is the way to get the rows in the same order in
which it has been inserted..?
RegardsWhy? What is your business case behind this?
In my experience an "order by" is used way too much without any real need to do it. Are your users interested to know in what order a few records from two years ago have been inserted? What about updates since that time? -
How can i select some row from multiple row in the same group of data
I want to select some row from multiple row in the same group of data.
ColumnA
Column B
1 OK
1 NG
2 NG
2 NG
3 OK
3 OK
I want the row of group of
ColumnA if ColumnB contain even 'NG'
row , select only one row which Column B = 'NG'
the result i want =
ColumnA Column B
1 NG
2 NG
3 OK
Thank youThat's some awful explanation, but I think this is what you were driving at:
DECLARE @forumTable TABLE (a INT, b CHAR(2))
INSERT INTO @forumTable (a, b)
VALUES
(1, 'OK'),(1, 'NG'),
(2, 'NG'),(2, 'NG'),
(3, 'OK'),(3, 'OK')
SELECT f.a, MIN(COALESCE(f2.b,f.b)) AS b
FROM @forumTable f
LEFT OUTER JOIN @forumTable f2
ON f.a = f2.a
AND f.b <> f2.b
GROUP BY f.a -
Import xml data in Access when multiple rows use the same fieldname
HI.
First of all sorry for my english :-) I have a LiveCycle Designer ES form with multiple rows that I send via e-mail as XML data.
example:
Row 1
Firstname: John Lastname: Dow
Row 2
Firstname: Steve Lastname: Austin
The exported XML is OK but when I want to import it into my Access database, only one row is imported. I pretty sure that the problem comes from the fact that may exported XML use the same fieldname (what is important if I want to import data in the correct Access field) but I don't know what to do to be able to import all the rows of the same Form.
Any idea?
Thanks a lot
FredericHi Viktor,
In case of order recognition rules you should increase the relevancy in the newer version of the cartridge so appropriate ORR will be triggered. In other xqueries, you can try using new namespace as a model variable for each and every version of the cartridge
Regards,
JP -
Trigger in mutation - Update another rows in the same table with a trigger
Hi ,
I try to do a before update trigger on a table , but the trigger is in mutation. I understand why it do that but my question is :
How can I update other rows in the same table when a UPDATE is made on my table??????
Here is my trigger :
CREATE OR REPLACE TRIGGER GDE_COMPS_BRU_5 BEFORE
UPDATE OF DEPARTEMENT--, DISCIPLINE, DEG_DEMANDE, CE_ETAB
ON GDEM.COMPOSITION_SUBV
FOR EACH ROW
Organisme : FQRNT-FQRSC
Date de création : 14-07-2011
Date de modification :
Modifié par :
Auteur : Johanne Plamondon
Description : Ce déclencheur s'executera lors de la modification
du responsable dans la table COMPOSITION_SUBV
DECLARE
V_OSUSER V$SESSION.OSUSER%TYPE;
V_PROGRAM V$SESSION.PROGRAM%TYPE;
V_TERMINAL V$SESSION.TERMINAL%TYPE;
V_MACHINE V$SESSION.MACHINE%TYPE;
V_MODULE V$SESSION.MODULE%TYPE;
V_LOGON_TIME V$SESSION.LOGON_TIME%TYPE;
V_AUDIT_ID NUMBER;
vSEQ NUMBER;
i NUMBER;
vID DEMANDE.ID%TYPE;
BEGIN
begin
SELECT OSUSER, PROGRAM, TERMINAL,MACHINE,MODULE, LOGON_TIME
INTO V_OSUSER,V_PROGRAM,V_TERMINAL,V_MACHINE,
V_MODULE,V_LOGON_TIME
FROM V$SESSION
WHERE TYPE = 'USER'
AND USERNAME = USER
AND LAST_CALL_ET IN (0,1)
AND ROWNUM < 2;
exception when others then null; end;
IF NVL(:NEW.SC_PART,' ') = 'CHC' THEN
SELECT COUNT(*)
INTO i
FROM DEMANDE
WHERE DEM_REF = :NEW.DEM_ID
AND PER_NIP = :NEW.PER_NIP;
IF i = 1 THEN
SELECT ID
INTO vID
FROM DEMANDE
WHERE DEM_REF = :NEW.DEM_ID
AND PER_NIP = :NEW.PER_NIP;
UPDATE COMPOSITION_SUBV
SET --CE_ETAB = :NEW.CE_ETAB,
--DISCIPLINE = :NEW.DISCIPLINE,
DEPARTEMENT = :NEW.DEPARTEMENT,
--DEG_DEMANDE = :NEW.DEG_DEMANDE,
DATE_MODIF = SYSDATE,
USER_MODIF = V_OSUSER
WHERE DEM_ID = vID
AND PER_NIP = :NEW.PER_NIP
AND ANNEE = :NEW.ANNEE;
END IF;
END IF;
/*EXCEPTION
WHEN OTHERS THEN
NULL;*/
END;A standard disclaimer, the mutating trigger error is telling you that you really, really, really don't want to be doing this. It generally indicates a major data model problem when you find yourself in a situation where the data in one row of a table depends on the data in another row of that same table. In the vast majority of cases, you're far better off fixing the data model than in working around the problem.
If you are absolutely sure that you cannot fix the data model and must work around the problem, you'll need
- A package with a collection (or global temporary table) to store the keys that are modified
- A before statement trigger that initializes the collection
- A row-level trigger that adds the keys that were updated to the collection
- An after statement trigger that iterates over the data in the collection and updates whatever rows need to be updated.
If you're on 11g, this can be simplified somewhat by using a compound trigger with separate before statement, row-level, and after statement sections.
Obviously, though, this is a substantial increase in complexity over the single trigger you have here. That's one of the reasons that it's generally a bad idea to work around mutating table exceptions.
Justin -
BEX : report with real and budget on the same line
Hi everyone,
I need to create a Bex report showing on the same line :
- budget WBS element stored in a DSO (DataSource 0CO_OM_WBS_1)
- used amount stored in another DSO (DataSource 0FI_GL_4)
Data are stored in 2 different DSOs.
If a create a multiprovided with both DSOs I will get 2 lines in my report as axes are different,no ?
Thanks for any idea.
AussieHi,
You can make use of infoset.You can also do a lookup from one dso to another ant transport the values in one dso.So by doin this alll your values will be stored in one place and then you can show the values in one line in report.
Please also give me the idea of keyfields of both dso's.
You can also use constant selection in report if you are using multiprovider through this to some extenet you can solve the problem of values in coming in two lines.
Also check out the below PDF for Displaying Result Row in One Line While Reporting On Multiproviderer.
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70dcd7b5-6a3d-2d10-c984-e835e37071a2?quicklink=index&overridelayout=true
Hope it helps.
Regards,
AL
Edited by: AL1112 on Aug 3, 2011 11:55 AM -
SUM two fileds from different rows from the same table
I would like to SUM two fileds from different rows from the same table but I don't know how to do that.
E.g.
BillingTransactionsIndex CreateDate UserType UserIndex TransType Reference Total Balance
2 6/5/2008 15:02 1 51 1 150 -288.2 -288.2
5 6/8/2008 11:55 1 51 1 157 -1.58674 -289.787
In the table above I want SUM fields Total and Balance for the first row and the the next row SUM 2nd row Total with 1st row Balance
Please help
ThanksSQL> with tbl as
2 (select 1 as ID, 90 as total from dual
3 union all
4 select 2 as ID, 23 as total from dual
5 union all
6 select 3 as ID, 15 as total from dual
7 union all
8 select 4 as ID, 20 as total from dual)
9 select id , total, sum(total) over (order by ID) as balance from tbl
10 /
ID TOTAL BALANCE
1 90 90
2 23 113
3 15 128
4 20 148
SQL> -
SUM two ROWS in the SAME Table
Hi,
I have a problem with this issue. I want to sum two rows from the same table, but I don´t know how to do that. I tried to do it with CTE, but always I get the same error "Ambiguous". I would like to ask you, if there is other manner to get that
data (sum two rows) and if it is possible to see examples about it.
Thank you in advanceHi Vaibhav,
I leave you my scrip:
USE Modelling
GO
--TABLE Aer_Lingus_Income_Statement
IF OBJECT_ID('Aer_Lingus_Income_Statement') IS NOT NULL
DROP TABLE Aer_Lingus_Income_Statement
GO
CREATE TABLE Aer_Lingus_Income_Statement
ID [nvarchar](255) NOT NULL,
Name_Account [nvarchar](255) NULL,
Company [nvarchar](255) NULL,
Level0_Account [nvarchar](255) NULL,
Level1_Account [nvarchar](255) NULL,
Level2_Account [nvarchar](255) NULL,
Level3_Account [nvarchar](255) NULL,
Level4_Account [nvarchar](255) NULL,
Level5_Account [nvarchar](255) NULL,
Level6_Account [nvarchar](255) NULL,
Level7_Account [nvarchar](255) NULL,
Level8_Account [nvarchar](255) NULL,
Year_2006 decimal (15,2) null,
Year_2007 decimal (15,2) null,
Year_2008 decimal (15,2) null,
Year_2009 decimal (15,2) null,
Year_2010 decimal (15,2) null,
Year_2011 decimal (15,2) null,
Year_2012 decimal (15,2) null,
Year_2013 decimal (15,2) null,
GO
ALTER TABLE Aer_Lingus_Income_Statement
ADD CONSTRAINT PK_Aer_Lingus_Income_Statement PRIMARY KEY (ID)
GO
INSERT INTO Aer_Lingus_Income_Statement
SELECT *
FROM Aer_Lingus_data_Income
IF OBJECT_ID('Aer_Lingus_Income_Statement_Historic') IS NOT NULL
DROP VIEW Aer_Lingus_Income_Statement_Historic
GO
CREATE VIEW Aer_Lingus_Income_Statement_Historic
as
Select Level0_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level0_Account ='Revenue'
Group by Level0_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account= 'Passenger revenue' and Level0_Account ='Revenue'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account= 'Ancillary revenue' and Level0_Account ='Revenue'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account= 'Other revenue' and Level0_Account ='Revenue'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account= 'Cargo revenue' and Level0_Account ='Revenue'
Group by Name_Account
UNION ALL
Select Level0_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level0_Account ='Operating expenses'
Group by Level0_Account
UNION ALL
Select Level1_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level1_Account ='Staff costs' and Level0_Account ='Operating expenses'
Group by Level1_Account
UNION ALL
Select Level1_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level1_Account ='Depreciation, amortisation and impairment' and Level0_Account ='Operating expenses'
Group by Level1_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Aircraft operating lease costs' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Fuel and oil costs' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Maintenance expenses' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Airport charges' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='En-route charges' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Distribution costs' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Ground operations, catering and other operating costs' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Level1_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level1_Account ='Other (gains)/losses - net' and Level0_Account ='Operating expenses'
Group by Level1_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Employee profit share' and Level0_Account ='Operating expenses'
Group by Name_Account
GO
WITH sumasRevenue
AS (
SELECT Name_Account, ID
, sum(Year_2006) AS Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
WHERE Level0_Account = 'Revenue'
GROUP BY Name_Account, ID
WITH ROLLUP
, total
AS (
SELECT Y2006,Y2007 ,Y2008,Y2009 ,Y2010 ,Y2011 ,Y2012 ,Y2013
FROM sumasRevenue
WHERE Name_Account IS NULL
sumasOperatingExpensive
AS (
SELECT Name_Account, ID
, sum(Year_2006) AS Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
WHERE Level0_Account = 'Operating expenses'
GROUP BY Name_Account, ID
WITH ROLLUP
, total1
AS (
SELECT Y2006,Y2007 ,Y2008,Y2009 ,Y2010 ,Y2011 ,Y2012 ,Y2013
FROM sumasOperatingExpensive
WHERE Name_Account IS NULL
SELECT distinct ID , s.Name_Account,
(s.Y2006* 1.0 - t.Y2006) AS [V2006] ,(s.Y2007* 1.0 -T.Y2007 ) as [V2007] , (s.Y2008* 1.0 /T.Y2008 ) as [V2008],(s.Y2009* 1.0 /T.Y2009 ) as [V2009],
(s.Y2010* 1.0 /T.Y2010 ) as [V2010],(s.Y2011* 1.0 /T.Y2011 ) as [V2011],(s.Y2012* 1.0 /T.Y2012 ) as [V2012],(s.Y2013* 1.0 /T.Y2013 ) as [V2013]
FROM sumasRevenue AS s , sumasOperatingExpensive AS t
Where ID IS NOT NULL
UNION ALL
SELECT distinct ID,COALESCE(s.Name_Account,'NON CURRENT ASSETS') AS Name_Account ,
sum (s.Y2006* 1.0 / t.Y2006) as V2006,sum (s.Y2007* 1.0 / t.Y2007) as V2007,sum (s.Y2008* 1.0/ t.Y2008) as V2008,sum (s.Y2009* 1.0/ t.Y2009) as V2009,sum (s.Y2010* 1.0/ t.Y2010) as V2010,
sum (s.Y2011* 1.0 / t.Y2011) as V2011,sum (s.Y2012* 1.0/ t.Y2012) as V2012,sum (s.Y2013* 1.0/ t.Y2013) as V2013
FROM sumasRevenue as s , sumasOperatingExpensive as t
Where ID IS NULL and Name_Account IS NULL
GROUP BY Name_Account, ID
WITH ROLLUP
select *
from Aer_Lingus_Income_Statement_Historic
Thank you in advance -
How to make every break column on the top of the rows in the same subgroup
hi, guys:
I was wondering if anyone could help me on this problem: I need to set up a break column on a classic report (I ma required to use classic report only), and it works, but I do not know how to make every break column on the top of the rows in the same subgroup. The break column only stays on the left to the rest columns as it is the first column. Anyone could help me on this problem? Here is the query:
select so.doc_number as "DOC Number", so.offender_id as "Offender ID", so.first_name||' '|| so.middle_name||' '||so.last_name as "Offender Name",
(select sc1.description from sor_code sc1 where sc1.code_id=so.race) as "Race",
(select sc2.description from sor_code sc2 where sc2.code_id=so.sex) as "Sex",
replace(replace(nvl2(sl.address1, sl.address1||' '||sl.address2 ||' '||sl.city ||' '||sl.county||' '||(select sc3.description from sor_code sc3 where sc3.code_id=sl.state)||' '||sl.zip, 'No Known Address'),'#'),',') as "Address",
(select sof.name||' '||sof.phone1||' '||sof.link from sor_offices sof where sof.office_id=sl.jurisdiction) as "Jurisidiction",
decode(rox.habitual, 'Y', 'Habitual', '') as "Habitual",
decode(rox.aggravated, 'Y', 'Aggravated', '') as "Aggravated",
floor(to_number(sysdate-so.date_of_birth)/365) as "Age"
from sor_location sl, sor_offender so, registration_offender_xref rox, sor_last_locn_v sllv
where rox.offender_id=so.offender_id
and sllv.offender_id(+)=so.offender_id
and sl.location_id(+)=sllv.location_id
and rox.status not in ('Merged')
and rox.reg_type_id=1
and upper(rox.status)='ACTIVE'
and nvl(rox.admin_validated, to_date(1,'J'))>=nvl(rox.entry_date, to_date(1,'J'))
and ((so.first_name is not null and upper(so.first_name) like '%'||upper(:P5_TF_FIRST_NAME)||'%') or (:P5_TF_FIRST_NAME is null))
and ((so.last_name is not null and upper(so.last_name) like '%'||upper(:P5_TF_LAST_NAME)||'%') or (:P5_TF_LAST_NAME is null))
and ((sl.address1||sl.address2 is not null and upper(sl.address1|| sl.address2) like '%'||upper(:P5_TF_ADDRESS)||'%')or (:P5_TF_ADDRESS is null))
and ((sl.city is not null and upper(sl.city) like '%'||upper(:P5_TF_CITY)||'%')or (:P5_TF_CITY is null))
and ((sl.county is not null and sl.county =:P5_SL_COUNTY)or (:P5_SL_COUNTY is null))
and (((select sc5.description from sor_code sc5 where sc5.code_id=sl.state and sc5.description=:P5_SL_STATE) is not null )or (:P5_SL_STATE is null))
and ((sl.zip is not null and sl.zip =:P5_TF_ZIP_CODE)
or (:P5_TF_ZIP_CODE is null))
union
select so.doc_number as "DOC Number", so.offender_id as "Offender ID", so.first_name||' '|| so.middle_name||' '||so.last_name as "Offender Name",
(select sc1.description from sor_code sc1 where sc1.code_id=so.race) as "Race",
(select sc2.description from sor_code sc2 where sc2.code_id=so.sex) as "Sex",
replace(replace(nvl2(sl.address1, sl.address1||' '||sl.address2 ||' '||sl.city ||' '||sl.county||' '||(select sc3.description from sor_code sc3 where sc3.code_id=sl.state)||' '||sl.zip, 'No Known Address'),'#'),',') as "Address",
(select sof.name||' '||sof.phone1||' '||sof.link from sor_offices sof where sof.office_id=sl.jurisdiction) as "Jurisidiction",
decode(rox.habitual, 'Y', 'Habitual', '') as "Habitual",
decode(rox.aggravated, 'Y', 'Aggravated', '') as "Aggravated",
floor(to_number(sysdate-so.date_of_birth)/365) as "Age"
from sor_location sl, sor_offender so, registration_offender_xref rox, sor_last_locn_v sllv
where rox.offender_id=so.offender_id
and sllv.offender_id(+)=so.offender_id
and sl.location_id(+)=sllv.location_id
and rox.status not in ('Merged')
and rox.reg_type_id=1
and upper(rox.status)='ACTIVE'
and nvl(rox.admin_validated, to_date(1,'J'))>=nvl(rox.entry_date, to_date(1,'J'))
and ((so.first_name is not null and upper(so.first_name) like '%'||upper(:P5_TF_FIRST_NAME)||'%') or (:P5_TF_FIRST_NAME is null))
and ((so.last_name is not null and upper(so.last_name) like '%'||upper(:P5_TF_LAST_NAME)||'%') or (:P5_TF_LAST_NAME is null))
and ((sl.physical_address1 is not null and upper(sl.physical_address1) like '%'||upper(:P5_TF_ADDRESS)||'%') or (:P5_TF_ADDRESS is null))
and ((sl.physical_city is not null and upper(sl.physical_city) like '%'||upper(:P5_TF_CITY)||'%') or (:P5_TF_CITY is null))
and ((sl.physical_county is not null and sl.physical_county =:P5_SL_COUNTY) or (:P5_SL_COUNTY is null))
and (((select sc5.description from sor_code sc5 where sc5.code_id=sl.physical_state and sc5.description=:P5_SL_STATE) is not null )or (:P5_SL_STATE is null))
and ((sl.physical_zip is not null and sl.physical_zip =:P5_TF_ZIP_CODE) or (:P5_TF_ZIP_CODE is null))
union
select so.doc_number as "DOC Number", so.offender_id as "Offender ID", so.first_name||' '|| so.middle_name||' '||so.last_name as "Offender Name",
(select sc1.description from sor_code sc1 where sc1.code_id=so.race) as "Race",
(select sc2.description from sor_code sc2 where sc2.code_id=so.sex) as "Sex",
replace(replace(nvl2(sl.address1, sl.address1||' '||sl.address2 ||' '||sl.city ||' '||sl.county||' '||(select sc3.description from sor_code sc3 where sc3.code_id=sl.state)||' '||sl.zip, 'No Known Address'),'#'),',') as "Address",
(select sof.name||' '||sof.phone1||' '||sof.link from sor_offices sof where sof.office_id=sl.jurisdiction) as "Jurisidiction",
decode(rox.habitual, 'Y', 'Habitual', '') as "Habitual",
decode(rox.aggravated, 'Y', 'Aggravated', '') as "Aggravated",
floor(to_number(sysdate-so.date_of_birth)/365) as "Age"
from sor_location sl, sor_offender so, registration_offender_xref rox, sor_last_locn_v sllv, sor_alias sa
where rox.offender_id=so.offender_id
and sa.offender_id=so.offender_id
and sllv.offender_id(+)=so.offender_id
and sl.location_id(+)=sllv.location_id
and rox.status not in ('Merged')
and rox.reg_type_id=1
and upper(rox.status)='ACTIVE'
and nvl(rox.admin_validated, to_date(1,'J'))>=nvl(rox.entry_date, to_date(1,'J'))
and ((sa.first_name is not null and upper(sa.first_name) like '%'||upper(:P5_TF_FIRST_NAME)||'%') or (:P5_TF_FIRST_NAME is null))
and ((sa.last_name is not null and upper(sa.last_name) like '%'||upper(:P5_TF_LAST_NAME)||'%') or (:P5_TF_LAST_NAME is null))
and ((sl.address1||sl.address2 is not null and upper(sl.address1|| sl.address2) like '%'||upper(:P5_TF_ADDRESS)||'%')or (:P5_TF_ADDRESS is null))
and ((sl.city is not null and upper(sl.city) like '%'||upper(:P5_TF_CITY)||'%')or (:P5_TF_CITY is null))
and ((sl.county is not null and sl.county =:P5_SL_COUNTY)or (:P5_SL_COUNTY is null))
and (((select sc5.description from sor_code sc5 where sc5.code_id=sl.state and sc5.description=:P5_SL_STATE) is not null )or (:P5_SL_STATE is null))
and ((sl.zip is not null and sl.zip =:P5_TF_ZIP_CODE)or (:P5_TF_ZIP_CODE is null))
union
select so.doc_number as "DOC Number", so.offender_id as "Offender ID", so.first_name||' '|| so.middle_name||' '||so.last_name as "Offender Name",
(select sc1.description from sor_code sc1 where sc1.code_id=so.race) as "Race",
(select sc2.description from sor_code sc2 where sc2.code_id=so.sex) as "Sex",
replace(replace(nvl2(sl.address1, sl.address1||' '||sl.address2 ||' '||sl.city ||' '||sl.county||' '||(select sc3.description from sor_code sc3 where sc3.code_id=sl.state)||' '||sl.zip, 'No Known Address'),'#'),',') as "Address",
(select sof.name||' '||sof.phone1||' '||sof.link from sor_offices sof where sof.office_id=sl.jurisdiction) as "Jurisidiction",
decode(rox.habitual, 'Y', 'Habitual', '') as "Habitual",
decode(rox.aggravated, 'Y', 'Aggravated', '') as "Aggravated",
floor(to_number(sysdate-so.date_of_birth)/365) as "Age"
from sor_location sl, sor_offender so, registration_offender_xref rox, sor_last_locn_v sllv, sor_alias sa
where rox.offender_id=so.offender_id
and sa.offender_id=so.offender_id
and sllv.offender_id(+)=so.offender_id
and sl.location_id(+)=sllv.location_id
and rox.status not in ('Merged')
and rox.reg_type_id=1
and upper(rox.status)='ACTIVE'
and nvl(rox.admin_validated, to_date(1,'J'))>=nvl(rox.entry_date, to_date(1,'J'))
and ((sa.first_name is not null and upper(sa.first_name) like '%'||upper(:P5_TF_FIRST_NAME)||'%') or (:P5_TF_FIRST_NAME is null))
and ((sa.last_name is not null and upper(sa.last_name) like '%'||upper(:P5_TF_LAST_NAME)||'%') or (:P5_TF_LAST_NAME is null))
and ((sl.physical_address1 is not null and upper(sl.physical_address1) like '%'||upper(:P5_TF_ADDRESS)||'%') or (:P5_TF_ADDRESS is null))
and ((sl.physical_city is not null and upper(sl.physical_city) like '%'||upper(:P5_TF_CITY)||'%') or (:P5_TF_CITY is null))
and ((sl.physical_county is not null and sl.physical_county =:P5_SL_COUNTY) or (:P5_SL_COUNTY is null))
and (((select sc5.description from sor_code sc5 where sc5.code_id=sl.physical_state and sc5.description=:P5_SL_STATE) is not null )or (:P5_SL_STATE is null))
and ((sl.physical_zip is not null and sl.physical_zip =:P5_TF_ZIP_CODE) or (:P5_TF_ZIP_CODE is null))I set up "Jurisdiction" to be displayed as the first column in report attributes and set up the first column to be break column, under the "When displaying a break column use this format, use #COLUMN_VALUE# subs", I fill in "Jurisdiction".lxiscas wrote:
Hi, fac586:
I am sorry for not being able to provide project online oracle to ask the question as some of the data needs to be approved to release.You don't need to use the actual data. Create simple test cases using data from Oracle's sample schemas: SCOTT, OE, HR etc.
I actually want something like this:
Jurisdiction: Bartlesville Police Department, 918-338-4001, http://www.cityofbartlesville.org/departments/police/
Smith , Carl Sherman ......
Smith , Tommy Nesby .....
Jurisdiction: Canadian County Sheriff's Office, 405-262-4787, Fax - 405-422-2430
Smith , Gabriel Ray ...
Smith , Michael Bert ...I omit the sensitive data with ...
but right now it shows as this way:
Jurisdiction: Bartlesville Police Department, 918-338-4001, http://www.cityofbartlesville.org/departments/police/ Smith , Carl Sherman ......
Smith , Tommy Nesby .....
Jurisdiction: Canadian County Sheriff's Office, 405-262-4787, Fax - 405-422-2430 Smith , Gabriel Ray ...
Smith , Michael Bert ...Is that possible to show the data as the upper way?The best way to do this is using a report with a custom named column template as in this example. See the following threads for solutions to similar problems:
<li>{thread:id=2402836}
<li>{message:id=9816577} -
Grid Layout - Getting two or more fields to display on the same line/row.
I am using version 4.2.
I have a form with a number of items.
I wish to control the display of the items so that some fields are beside each other (on the same line or row).
I have set the grid layout as follows:
:PX_ITEM1
Start New Row: Yes
Column: Automatic
Column Span: Automatic
:PX_ITEM2
Start New Row: No
Column: Automatic
New Column: Yes
Column Span: Automatic
When I do this the items are not displayed on the same row.
I can see when you change the "Start New Row" from No to Yes, the item fields ARE moved into the same <Div> that controls the row, but they just aren't displaying how I would like them.
Has anyone got this working?
Amanda.Hi Amanda,
I believe I have discovered the cause of the issue you are facing.
The problem is with the "Alert Region" region template and that it does not have any display points specified so indicate the number of grids that can fit in its region body. Without having any display points, the grid layout system attempts to use all columns available to its container. However, because the Alert Region has additional padding within, the columns will not fit and wrap to the next line.
To fix this issue, you will have to modify the "Alert Region" region template, go to "Display Points" and click Add Row. You will need to enter the following fields:
Name: Region Body
Template Substitution: BODY
Grid Support: Checked
Maximum Fixed Grid Columns: -1
This will fix the issue for you. I've logged a bug within our bug system to track this so we can fix it in a future release of APEX.
Best,
Shakeeb -
Cross tab template Formatting. Two Row Groups cannot be on the same line
Hi
I have a cross tab template(Vetsriselvan favor) where it has Multiple Row groups. In the RTF template I want them to be on the same line but somehow it works only if they are one below the other. In this template Comp is the First Group Row then Acct is 2nd Group Row and Expense is the 3rd Group Row. Period is the Column. I want all the Group rows start from the same line instead one below the other. Is it possible to do it?
Comp Acct Expense Period
<?for-each-group:/BIOFASPRJ/LIST_G_SUMDEPR1PERACCT/ <[?for-each-group@column:G_PERIOD_NAME[./PERIOD_NAME!=''];PERIOD_NAME|mailto:?for-each-group@column:G_PERIOD_NAME[./PERIOD_NAME!=''];PERIOD_NAME]?>
G_SUMDEPR1PERACCT/LIST_G_COMP_CODE/G_COMP_CODE;./COMP_CODE?> F_comp
<?for-each-group:./LIST_G_ACCT/G_ACCT [LIST_G_DESCRIPTION/G_DESCRIPTION/LIST_G_PERIOD_NAME/G_PERIOD_NAME/LIST_G_DEPR1/G_DEPR1];ACCT?> <?variable@incontext:G1;current-group()?>acc
<?for-each-group:./LIST_G_DESCRIPTION/G_DESCRIPTION[LIST_G_PERIOD_NAME/G_PERIOD_NAME/LIST_G_DEPR1/G_DEPR1];DESCRIPTION?><?variable@incontext:G2;current-group()?>accUpload the template here
http://apps2fusion.com/forums/viewforum.php?f=60
or
Send me the template and xml to fusionDOTobjectATgmail.com
Maybe you are looking for
-
I just rebuilt my mail inbox, 1 iCloud account and 2 other imap accounts, and everything is gone. Nothing on the remote servers either and on all my iCloud sync mobiles. How can i recover all my emails? Thanks it's all my work!!!!!!!
-
Streaming from my iPad to my tv is not working, it keeps saying the iTunes accounts are different but I've checked it a ton of times and its the same, anyone had the same problem?
-
How do I change "open new window" tab behaviour?
I used to be a Firefox user ages ago, and then switched to Chrome for awhile. I'm coming back now, and I'm noticing some strangeness with tabs and "new windows". Can't figure out how to get around it. My "Home Page" is set up to open three tabs. One
-
Is it possible to get the 'Switch to tab' option higher when typing in the Awesome Bar?
Hello, I'm currently running the latest version of Aurora and although I really like it, there's one thing that kind of annoys me. I'm often running more than 100 tabs at once, and searching all of them to find the desired tab takes a long time, ther
-
So I'm pretty sure that the logmein software (logmein.com) has somehow broken my Finder or a link between the System and the Finder. I've uninstalled logmein, but the damage has been done. Here's what's happening... My computer is set to turn on in t