Result in same row instead of two rows
I have to select same field on two different condition ie.
select
(case when data_type_id = 1 then hrscycles else 0 end) totalhours
,(case when data_type_id = 10 then hrscycles else 0 end) totalcycles
from mytable
Problem is query is returning 2 rows whereas i want result in single row.Is there any other solution?
select (case when data_type_id = 1 then hrscycles else 0 end) totalhours,
(case when data_type_id = 10 then hrscycles else 0 end) totalcycles
from mytableyour query in the above will return two columns and will return multiple rows depending on the data your table have.
maybe you want single column?
select (case when data_type_id = 1 then hrscycles
else 0
end) attribute1
from mytable
union all
select (case when data_type_id = 10 then hrscycles
else 0
end) attribute1
from mytableor if you want a multiple rows into a single column:
SQL> select * from pivot_tab;
COL1 COL2
1 a
1 b
1 c
2 h
2 h
SQL> select p.col1,
2 substr(max(substr(sys_connect_by_path (p.col2,','),2)),1,60)
3 as col2
4 from (select col1,
5 col2,
6 row_number() over (partition by col1 order by col1, col2) rn
7 from pivot_tab) p
8 start with p.rn = 1
9 connect by p.rn = prior p.rn + 1
10 and prior p.col1 = p.col1
11 group by col1;
COL1 COL2
1 a,b,c
2 h,h
SQL>
Similar Messages
-
Producedure givng two rows instead of one row
Hi
Please find below my procedure..when I execute this proc...displays two rows instead of one row. Please help me incase if I did mistake.
CREATE PROCEDURE SP_CWCTravel_Cruise_Amenities_S(
@Cruise_Line_Code varchar(2500) = NULL,
@Ship_Code varchar(2500) = NULL,
@Sail_Id varchar(100) = NULL,
@Base_Price decimal(8, 2),
@Category_Groups varchar(2500) = NULL,
@Categories varchar(2500) = NULL,
@Rate_Codes varchar(2500) = NULL,
@Booking_Date VARCHAR( 10 ),
@Sail_Start_Date VARCHAR( 10 )
AS
BEGIN
SELECT TOP 1 *
FROM CWCTravel_Cruise_Amenities_Definition as cad
JOIN CWCTravel_Cruise_Amenities_Definition_Date_Range AS caddr
ON cad.id = caddr.Amenities_Definition_Id
WHERE Cruise_Line_Code in (SELECT item FROM SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Cruise_Line_Code))
AND (Min_Base_Price = 0 OR Min_Base_Price <= @Base_Price)
AND (Max_Base_Price = 0 OR Max_Base_Price >= @Base_Price)
AND (Ship_Code IS NULL OR Ship_Code = '' OR Ship_Code IN (SELECT item FROM SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Ship_Code)))
AND (Sail_Id IS NULL OR Sail_Id = '' OR Sail_Id IN (SELECT item FROM SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Sail_Id)))
AND (Rate_Codes IS NULL OR Rate_Codes = '' OR ((SELECT COUNT(*) FROM
(SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Rate_Codes)) A,
(SELECT REPLACE(REPLACE(Item,'?', '_'), '*', '%') Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(Rate_Codes)) B
WHERE A.Item LIKE B.Item) > 0))
AND (Category_Groups IS NULL OR Category_Groups = '' OR ((SELECT COUNT(*) FROM
(SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Category_Groups)) A,
(SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(Category_Groups)) B
WHERE A.Item LIKE B.Item) > 0))
AND (Categories IS NULL OR Categories = '' OR ((SELECT COUNT(*) FROM
(SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Categories)) A,
(SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(Categories)) B
WHERE A.Item LIKE B.Item) > 0))
AND (@Booking_Date is null or @Booking_Date=''
OR (( caddr.from_date IS NULL OR caddr.from_date <= @Booking_Date ) AND ( caddr.to_date IS NULL OR caddr.to_date >= @Booking_Date )
AND (( caddr.date_range_type IS NULL ) OR ( caddr.date_range_type = 'BOOK_DATE' ))) )
union
SELECT TOP 1 *
FROM CWCTravel_Cruise_Amenities_Definition as cad
JOIN CWCTravel_Cruise_Amenities_Definition_Date_Range AS caddr
ON cad.id = caddr.Amenities_Definition_Id
WHERE Cruise_Line_Code in (SELECT item FROM SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Cruise_Line_Code))
AND (Min_Base_Price = 0 OR Min_Base_Price <= @Base_Price)
AND (Max_Base_Price = 0 OR Max_Base_Price >= @Base_Price)
AND (Ship_Code IS NULL OR Ship_Code = '' OR Ship_Code IN (SELECT item FROM SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Ship_Code)))
AND (Sail_Id IS NULL OR Sail_Id = '' OR Sail_Id IN (SELECT item FROM SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Sail_Id)))
AND (Rate_Codes IS NULL OR Rate_Codes = '' OR ((SELECT COUNT(*) FROM
(SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Rate_Codes)) A,
(SELECT REPLACE(REPLACE(Item,'?', '_'), '*', '%') Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(Rate_Codes)) B
WHERE A.Item LIKE B.Item) > 0))
AND (Category_Groups IS NULL OR Category_Groups = '' OR ((SELECT COUNT(*) FROM
(SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Category_Groups)) A,
(SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(Category_Groups)) B
WHERE A.Item LIKE B.Item) > 0))
AND (Categories IS NULL OR Categories = '' OR ((SELECT COUNT(*) FROM
(SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(@Categories)) A,
(SELECT Item FROM dbo.SF_CWCTravel_GetStrTableFromCommaSeparatedStr(Categories)) B
WHERE A.Item LIKE B.Item) > 0))
AND (@Sail_Start_Date is null or @Sail_Start_Date=''
OR (( caddr.from_date IS NULL OR caddr.from_date <= @Sail_Start_Date ) AND ( caddr.to_date IS NULL OR caddr.to_date >= @Sail_Start_Date )
AND (( caddr.date_range_type IS NULL ) OR ( caddr.date_range_type = 'TRAVEL_DATE' ))) )
ORDER BY Cruise_Line_Code DESC, Ship_Code DESC, Sail_Id DESC, Rate_Codes DESC, Category_Groups DESC, Categories DESC
ENDWhile executing this SP
I am getting the following results.
2043 23-07-2010 AM 11:22:10 23-08-2011 PM 04:57:19 8 princess caribbeanPrincess 2043 20-08-2011 AM 12:00:00 30-11-2011 AM 12:00:00 BOOK_DATE
2043 23-07-2010 AM 11:22:10 23-08-2011 PM 04:57:19 8 princess caribbeanPrincess 2043 01-10-2011 AM 12:00:00 30-11-2011 AM 12:00:00 TRAVEL_DATE
I need only the first record.
Thanks in adv
Rekha871270 wrote:
Hi
Please find below my procedure..when I execute this proc...displays two rows instead of one row. Please help me incase if I did mistake.Seriously?
You wrote a query against tables we've never seen, containing data we can't possibly have any idea about and you expect us to be able to help you?
Please go discuss this with someone in your organization who understands the data model and have them explain to you how it is supposed to work.
Put yourself in our situation (forum volunteers) ... if we threw some arbitrary code with no explanation as to what it does, what the data model looks like and what's supposed to be happening, do you think you'd be very successful ? -
Query result area on the first row instead of last row
Hi BI experts,
I want to display the result of the BI query at the first row instead of last row.Could somebody help me how to accomplish this.
I tried with the layout->move result area but could not be possible.
I need your kind suggetion.
Thanks.hi jyuoti,
Further, open your query in query designer, look at the query property, under the tab "rows/columns"
change the result position of rows to "Below", you can see the preview there itself.
This should solve your problem.
Best Regards,
*Assign points if you find the answer useful. -
Showing report data columns into two rows instead of one row using SSRS 2012
Hi All,
I have a ssrs report with 13 columns and I want to show those 13 columns data into two rows instead of showing in one row. please send me step by step process.
id fullname firstname lastname mailingaddress billingaddress
city state zipcode
1 ABC A C
xyz xyz123 york
PA 12345
homephone cellphone workphone company
1234567890 4567890123 0123456789 ABC,Inc
id fullname firstname lastname mailingaddress billingaddress
city state zipcode
2 XYZ X Z
abc abc123 lewisburg
PA 54321
homephone cellphone workphone company
4567890123 0123456789 1234567890 xyz,Inc
id fullname firstname lastname mailingaddress billingaddress
city state zipcode
3 BCD B D
123abc xyz123 leesburg PA
54123
homephone cellphone workphone company
4567895623 0783456789 1238967890 Hey,Inc
Thanks in advance,
RH
sqlDo a right mouse click on the left, gray row marker => "Insert Row"=> "Inside Group
- Above or Below", then you get a second detail row.
Olaf Helper
[ Blog] [ Xing] [ MVP] -
I need to retrieve the a set of rows in between two rows from a table.
consider employees table and primary key employee_id.
With out using EMPLOYEE_ID column in the where clause or between clause, I need to get the records between 104 and 116 or a set of records between two rows.
Can any one help me in this... i know this is simple but am just a fresher to oracle development... help me grow....
Thanks,
Arunya at last i got the out put... thank guys for thinking with me....
SELECT rownum, employee_id FROM (SELECT rownum, employee_id FROM employees ORDER BY employee_id)
WHERE ROWNUM <=8
MINUS
SELECT rownum, employee_id FROM (SELECT rownum, employee_id FROM employees ORDER BY employee_id) WHERE ROWNUM <= 4 -
Datagrid: Vertical Rows instead of Horizontal Rows
Hi,
Usually, inside a datagrid there are rows and columns.
The rows shows ex. one product for each line. Each product has some properties like number, color, weight,...
What we wanted to do is not to show one product per line, but 1 product per column: --> see the example
Normal Datagrid:
Number Description Color Weight ...
1 Product 1 red 10 kg
2 Product 2 green 15 kg
3 Product 3 blue 5 kg
What we want is:
Number 1 2 3
Description Product 1 Product 2 Product 3
Color red green blue
Weight 10 kg 15 kg 5 kg
Possible to do with standard Flex SDK?
Did anyone write such a component already with Flex 3 or Flex 4?
Thanks for any help on that issue.A pivot table is something else...
To change the datasource is possible, but the result is not what is correct.
cause:
- The selection of one product must be a vertical selection, and not a horizontal one.
- The column header must be at the left side, and not at the top!
But yes, sure, everything is possible to develop....
thanks anyway :-) -
I am new to Livecycle. I have created a table where I can add one row and delete one row. What I am trying to achieve, is to be able to add two rows and remove two rows at the same time.
Is this possible?
thank youUse the action builder as described before.
In order to do two rows at the same time you'll have to:
In you're Heirarchy panel, Control Select Row1 and Row2.
Then right click and choose "Group as Selection"
Now select your AddBtn and add the actionbuilder code.
Contition: When button addBtn is clicked
Result: Add a new Instance of selectionGroupedRows
now when you test and click the add button, both rows will duplicate. Do the same thing for the delBtn.
Hope this helps. -
Line of text in two rows in a check box
Greets
Ive been working in a poll, and i use a check box in some part, but de question its to long to put it in
i have the same problem with the text box, but with the command it can be possible to put a long question in two rows, but that command line doesnt work with check boxes
there are any form to make a long question of one row, into a two row question in check box component??There is a multiline button example you can adapt for checkboxes on my blog.
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui -
Missing rows / output only one row in a Report after applying patchset 2
Hi.
We use Reports Builder for 10g R2. We had the problem with our AS 10g R2 on windows 2003, that some reports creates duplicate rows when it is a ASCII report (desformat = delimited), see Bug 3340546.
Now we apply Patchset 2 on a local machine, to test the functionality. It fix the problem (look in metalink doc ID 398955.1 under "2.12 Oracle Reports Developer Bugs")-
But now most csv reports creates only one row instead of multiple rows.
We run reports on our local machine with OC4N and local started Form (via Forms Builder) to generate the reports (local started report server) from DevSuite).
When we start the reports with desformat=delimited the txt-file has only the header row and one data row (instead of multiple ones).
And when we generate the same report with desformat=delimiteddata it looks fine and generates all rows as expected.
We found neither here in the forum or in metalink knowledge base nor on the internet.
Have you any suggestions for us how to fix this problem?
Using delimiteddata is now acceptable solution for us, because delimited is easier to use.
Thanks for your help!Hey folks.
We have solved the problem. :)
We applied PatchSet2 for 10gR2. But we don´t know how the csv-report outputs only 1 data-row instead of several rows.
Than we create a similar report (with the same sql-query) as a new one with the reports builder assistant.
This one works pretty fine. So we looked for the attributes and see the "max. number datasets for each site" and it was in the new one set to 0 and in our old one set to 1.
So we change this and ... the old one works pretty fine! :)
So the problem is, that this attribute does not had any consequences in the old version. But since we update with PatchSet 2 it respect this attribute but we don´t "see" it.
Hope this helps others. -
When using private browsing to view image results in Safari 5.1.3, only the first two rows of results are visible, the following four or so rows display greyed out place holders, the remainder of the results page is blank, and the safe search button is inoperable. When I turn off private browsing and refresh the page, everything works again.
Anyone else having this problem?I have got the same behaviour after the last Safari Update to 5.1.3. It seems that Safari now handles some scripts in a new way. If you debug the Google Website, you will see, that there is some Javascript Error, that seems to prevent to write into local cache. After some searching I wasn't able to finde a solution for this problem, other then disabling Javascript while private browsing to prevent the script loading. You then are able to use Google with the old layout. The option to disable JavaScript can be found in the Menu "Developer", wich has to be enabled in Safari in the options first.
In my opinion this is a bug that is now occuring, because Apple changed something in private browsing and that has to be fixed by Google now, to run again. Or we will have to wait for 5.1.4, as you can read online Apple will change and bugfix the javascript engine in that version, perhaps this fixes the problem as well. I hope so!
If anyone is in the developer program perhaps you could test this with the beta of 5.1.4 and tell us if it works. -
Get the two rows of customer with same amount value within consecutive year
Hi,
Below are sample data, what I would like to do is pull the customer along with their two finance details that have the same amount within the two consecutive year. Please note that there are many customers and not all customers are have these criteria, so the query should not include those customers.
Like in my sample data the result should be:
(first row)
165321 John King Magazine 01/03/2007 30/03/2011 10/02/2009 180.00
(second row)
165321 John King Magazine 01/03/2007 30/03/2011 06/12/2008 180.00
Customer Table:
ID Name Product Start Delivery End Delivery
165321 John King Magazine 01/03/2007 30/03/2011
165322 Bryan Lee Magazine 15/04/2002 30/04/2011
Finance Table:
ID Invoice Date USD Amount
165321 10/02/2009 180.00
165321 10/02/2009 120.00
165321 06/12/2008 180.00
165321 20/05/2007 99.00
165321 12/03/2007 150.00
165321 07/03/2007 180.00
165322 01/01/2003 124.00
165322 30/05/2002 160.00
165322 20/04/2002 99.00
Thank you..Hi,
Depending on your exact requirements, you can do something like this:
WITH got_this_yr AS
SELECT id
, MIN (invoice_date) AS invoice_date
, usd_amount
, EXTRACT (YEAR FROM invoice_date) AS this_yr
FROM finance
-- WHERE ... -- any filtering goes here
GROUP BY id
, usd_amount
, EXTRACT (YEAR FROM invoice_date)
, got_neighbor_values AS
SELECT id
, invoice_date
, usd_amount
, this_yr
, LAG (this_year) OVER ( PARTITION BY id
, usd_amount
ORDER BY this_year
) AS prev_year
, LEAD(this_year) OVER ( PARTITION BY id
, usd_amount
ORDER BY this_year
) AS next_year
FROM got_this_yr
SELECT n.id
, c.name
, c.product
, c.start_delivery
, c.end_delivery
, n.invoice_date
, n.usd_amount
FROM got_neighbor_values n
JOIN customer c ON c.id = n.id
WHERE n.this_year IN ( n.prev_year + 1
, n.next_year - 1
ORDER BY n.id
, n.usd_amount
, n.invoice_date
;If you'd care to post CREATE TABLE and INSERT statements for the sample data, then I could test this.
This used the analytic LAG and LEAD functions to find the previous and next years when the same amount occurred with the same id. Since we want to use this value in a WHERE clause, it has to be computed in a sub-query (got_neighbor_vlues) first; analytic functions are always computed after the WHERRE clause is applied.
In the case of the very first year, LAG will return NULL, and in the case of the very last year, LEAD will return NULL. That's okay for our purposes; we just need something such that the WHERE clause of the main query will be TRUE if and only if one of the adjacent rows was a consecutive year.
Why don't you want a row for 2007 in the results? It looks like the same customer had the exact same amount in 2007, 2008 and 2009.
What happens if the same customer has the exact same amount 2 (or more) times in the same calendar year? The query above uses the earliest one in each year, and ignores the others. If that's not what you want, then post the results you do want
Edited by: Frank Kulash on Nov 15, 2010 10:36 AM
Included cutomer table -
Compare two rows in same table
Hi,
I want to compare two rows (some columns) in the same table, and if the data in the data columns is different, I want to pick the latest one. The table is date tracked. For instance I have an address table with different addresses for an employee with effective date. I want to be able to pick the latest row if the postal code is different for the 2 rows. Is this possible in sql. I can do this in Pl/sql, but dont want to use it. Eg
address_id, postal_code, person_id,last_update_date
123, pn123,1,12-JAN-01
124,pu124,1,13-JAN-01
I want to be able to retrieve just the second line.
Any help is appreciatedWelcome to the forum!
Whenever you post please provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
>
The table is date tracked. For instance I have an address table with different addresses for an employee with effective date. I want to be able to pick the latest row if the postal code is different for the 2 rows.
>
Your question is a little confusing because you are using terms like 'date tracked' and 'effective date' without explaining exactly what your definitions of those terms is.
Why do you want the latest record ONLY if the postal code is different? What if the address is different? Then which record do you want?
Why not just take the record for each person/company that has the latest date? If the data is the same then it doesn't which record you get so the one with the latest date will do. And if the data is different taking the one with the latest date gives you the latest data.
The classic definition of effective date is 'the date the information becomes effective'. Information with a given effective date is NOT in effect before that date and is SUPERCEDED when data is entered with a later effective date if the actual date is later than or equal to the effective date. Using your data
>
123, pn123,1,12-JAN-01
124,pu124,1,13-JAN-01
>
The first record IS NOT effective for dates prior to 12-JAN-01. In fact for a query looking for data prior to that date there isn't any data.
The first record is also NOT effective for dates on or after 13-JAN-01. Only the second record is effective.
If you added a record for 14-JAN-01 this record would not be effective until on or after that date (i.e. not for another 4 1/2 months).
So for the classic definition of effective date the query needs to provide the AS OF date to use to obtain the data. If, as in your system, you are not allowed to create records with dates in the future and you just want the latest record then you can just select the record with the MAX(myDate) value for the given person_id, address_id or whatever your key values are.
Edited by: rp0428 on Aug 11, 2012 7:50 AM -
Compare two rows in a same table
Dear all
I need to compare two rows in the same table, I dont know hoe to do it in pl/sql. Some one please help me on this.
example:
tr br price
xya0001 ama7 12
xya0003 ama6 14
xya0004 ama7 16
in the table tr is a unique value for each row, I need to compare price column and see whether the first value is less or greater than the next value and, if it is greater put the corresponding br value to a variable and if it is smaller put the corresponding br value to another variable. I dont know a method to do it, as I'm new to pl/sql. Some one please help me in thisnot sure what you intend to do as you have mentioned that "TR" is unique and you just want to compare each record with just the next record. Hope below query helps. The value "G" or "L" in flag would indicate if the current records price is greater than or less than the price in next record.
select tr,br,price,col4, case when price> col4 then 'G' when price< col4 then 'L' end flag from (
select tr,br,price,lag(price,1,0) over(order by tr) col4 from testcomp
) -
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 -
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
-
How do I move a freeze frame from iMovie 11 as a photo into iPhoto?
In prior versions of iMovie, I could isolate a freeze frame or still from the movie clip and then move it somewhere and it would become a regular photo to be manipulated in iPhoto. How do I do that in iMovie 11?
-
XA error with Oracle 9.2.0.x / Weblogic 6.1
I have encountered some problems when accessing Oracle 9i (9.2.0.2) via Weblogic6.1 sp3 . The problem occurs when a stateless session bean invokes a DAO that get a connection from the datasource. 04.03.2003 17:29 ERROR (SingleTableDAO.java:394) - no.
-
Hey guys.Let me start off buy saying that I **do** have AppleCare as of now. I've had my MacBook Pro Retina 13" Laptop for about 1-2 years and I haven't had much to complain about. However, my laptop's charger has started to fray and charging my lapt
-
Hi, I have 3 fields (quanity) displayed in an ALV report. I need to have the sum of the field values of these columns displayed. The code that I have written as suggested by Amit is: (this is just for one field). Its giving a dump. Please advise me o
-
How do I record with presenter notes in view?
I want to develop and rehearse a presentation by recording it. The ideal way to do that would be by having the presenter display visible while I record it. That would allow me to view my notes, next slide and timing as I record. However, the default