Cross Tab Query - Help
Dear users,
I have a query as below:
select a$acct$company company,
a$period_name "Period Name",
a$acct$location location,
a$acct$prime_sub "Prime Sub",
sum (balance) balance
from apps_rpt.us_gl_balances
where a$acct$prime_sub between '300001' and '313099'
and a$period_name = 'DEC-01'
and a$acct$company in ('5110')
group by a$period_name, a$acct$location, a$acct$company, a$acct$prime_sub
order by a$acct$prime_sub;
Sample output of the above query is:
COMPANY Period Name LOCATION Prime Sub BALANCE
5110 DEC-01 50008 300001 0.00
5110 DEC-01 52424 300001 0.00
5110 DEC-01 52513 300001 0.00
5110 DEC-01 50008 300008 201315.00
5110 DEC-01 50095 300008 10403.17
5110 DEC-01 50107 300008 0.00
5110 DEC-01 50108 300008 -1099236.04
5110 DEC-01 50180 300008 0.00
5110 DEC-01 51628 300008 -6396.02
5110 DEC-01 51734 300008 -5896.51
5110 DEC-01 51735 300008 -8525.78
5110 DEC-01 52423 300008 -7268.64
5110 DEC-01 52424 300008 -6945.65
5110 DEC-01 52428 300008 -7845.70
5110 DEC-01 52513 300008 -11309.44
5110 DEC-01 52514 300008 -10272.08
5110 DEC-01 52515 300008 -3861.72
5110 DEC-01 52516 300008 -6685.85I need to write a cross tab query whose output should be some thing as below:
300001 300008
50008 0 201315.00
52424 0 -6945.65
52513 0 -11309.44
50095 0 10403.17
50107 0 0
50108 0 -1099236.04
50180 0 0
51628 0 -6396.02
51734 0 -5896.51
51735 0 -8525.78
52423 0 -7268.64
52428 0 -7845.70
52514 0 -10272.08
52515 0 -3861.72
52516 0 -6685.85from the above cross tab results 300001 and 300008 are Prime Sub and the amount shown is Balance. The columns to the left side is Location. Company and Period Name remain the same for all the rows.
It would great if some one can assist me in writing a cross tab query to display results as shown above.
Thanks
Sandeep
Frank,
Thanks for your reply. I Tried your method of Dynamic Pivot, but its not working.
My dynamic_pivot_subscript.sql script is :
SELECT DISTINCT
', MAX(DECODE(PRIME_SUB,'|| PRIME_SUB||',' AS txt1,
'BALANCE,0)) AS '||prime_sub AS txt2
FROM
SELECT a$acct$location AS LOCATION
, a$acct$prime_sub AS PRIME_SUB
, SUM(BALANCE) AS BALANCE
FROM apps_rpt.us_gl_balances
WHERE a$acct$prime_sub BETWEEN '300001' AND '313099'
AND a$period_name = 'DEC-01'
AND a$acct$company IN ('5110')
GROUP BY a$acct$location,a$acct$prime_sub
);Sql Plus session is as follows :
-- Restore SQL*Plus features suppressed earlier
SET FEEDBACK ON
SET PAGESIZE 50
SPOOL p:\sql\cookbook\dynamic_pivot.lst
select LOCATION
@@dynamic_pivot_subscript
from
SELECT a$acct$location AS LOCATION
, a$acct$prime_sub AS PRIME_SUB
, SUM(BALANCE) AS BALANCE
FROM apps_rpt.us_gl_balances
WHERE a$acct$prime_sub BETWEEN '300001' AND '313099'
AND a$period_name = 'DEC-01'
AND a$acct$company IN ('5110')
GROUP BY a$acct$location,a$acct$prime_sub
GROUP BY LOCATION
SPOOL OFFWhen i use sql plus session then its giving me the following error:
@@dynamic_pivot_subscript
ERROR at line 2:
ORA-02019: connection description for remote database not found
(1) The version of Oracle (and any other relevant software) you're using
Ans :
Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
With the Partitioning option
JServer Release 8.1.7.4.0 - 64bit Production
I either use Toad or Sql Navigator
Similar Messages
-
Cross tab query dynamically.
Hi,
i want to do crosstab in my query. but the data was not static its dynamic.
CREATE TABLE ABTEST
SEC_ID NUMBER,
MONYEAR VARCHAR2(10 BYTE),
NUM NUMBER
SET DEFINE OFF;
Insert into ABTEST
WHERE
(SEC_ID, MONYEAR, NUM)
Values
(91, '200802', 13);
Insert into ABTEST
WHERE
(SEC_ID, MONYEAR, NUM)
Values
(91, '200803', 25);
Insert into ABTEST
WHERE
(SEC_ID, MONYEAR, NUM)
Values
(91, '200804', 26);
Insert into ABTEST
WHERE
(SEC_ID, MONYEAR, NUM)
Values
(91, '200805', 13);
Insert into ABTEST
WHERE
(SEC_ID, MONYEAR, NUM)
Values
(91, '200806', 10);
Insert into ABTEST
WHERE
(SEC_ID, MONYEAR, NUM)
Values
(91, '200807', 11);
Insert into ABTEST
WHERE
(SEC_ID, MONYEAR, NUM)
Values
(91, '200808', 5);
Insert into ABTEST
WHERE
(SEC_ID, MONYEAR, NUM)
Values
(91, '200809', 14);
Insert into ABTEST
WHERE
(SEC_ID, MONYEAR, NUM)
Values
(91, '200810', 17);
Insert into ABTEST
WHERE
(SEC_ID, MONYEAR, NUM)
Values
(91, '200811', 12);
Insert into ABTEST
WHERE
(SEC_ID, MONYEAR, NUM)
Values
(91, '200812', 12);
COMMIT;
Currently it looks like below.
SEC_ID MONYEAR NUM
91 200802 13
91 200803 25
91 200804 26
91 200805 13
91 200806 10
91 200807 11
91 200808 5
91 200809 14
91 200810 17
91 200811 12
91 200812 12
I want to display the data like below.
sec_id 200802 ........200812
91 13 12is there any can we do that by sql query or procedure. The dates are not limited its dynamic.
Please help meout.
Thanks & Regards,
Venkat.Hi,
The number of columns has to be hard-coded.
If you don't know the number of columns until run-time, then you have to use dynamic SQL where, at run-time, you figure out how many columns are needed and write that many columns.
See the script below for one way of doing that in SQL*Plus.
How to Pivot a Table with a Dynamic Number of Columns
This works in any version of Oracle
The "SELECT ... PIVOT" feature introduced in Oracle 11
is much better for producing XML output.
Say you want to make a cross-tab output of
the scott.emp table.
Each row will represent a department.
There will be a separate column for each job.
Each cell will contain the number of employees in
a specific department having a specific job.
The exact same solution must work with any number
of departments and columns.
(Within reason: there's no guarantee this will work if you
want 2000 columns.)
Case 0 "Basic Pivot" shows how you might hard-code three
job types, which is exactly what you DON'T want to do.
Case 1 "Dynamic Pivot" shows how get the right results
dynamically, using SQL*Plus.
(This can be easily adapted to PL/SQL or other tools.)
PROMPT ========== 0. Basic Pivot ==========
SELECT deptno
, COUNT (CASE WHEN job = 'ANALYST' THEN 1 END) AS analyst_cnt
, COUNT (CASE WHEN job = 'CLERK' THEN 1 END) AS clerk_cnt
, COUNT (CASE WHEN job = 'MANAGER' THEN 1 END) AS manager_cnt
FROM scott.emp
WHERE job IN ('ANALYST', 'CLERK', 'MANAGER')
GROUP BY deptno
ORDER BY deptno
PROMPT ========== 1. Dynamic Pivot ==========
-- ***** Start of dynamic_pivot.sql *****
-- Suppress SQL*Plus features that interfere with raw output
SET FEEDBACK OFF
SET PAGESIZE 0
SPOOL p:\sql\cookbook\dynamic_pivot_subscript.sql
SELECT DISTINCT
', COUNT (CASE WHEN job = '''
|| job
|| ''' ' AS txt1
, 'THEN 1 END) AS '
|| job
|| '_CNT' AS txt2
FROM scott.emp
ORDER BY txt1;
SPOOL OFF
-- Restore SQL*Plus features suppressed earlier
SET FEEDBACK ON
SET PAGESIZE 50
SPOOL p:\sql\cookbook\dynamic_pivot.lst
SELECT deptno
@@dynamic_pivot_subscript
FROM scott.emp
GROUP BY deptno
ORDER BY deptno
SPOOL OFF
-- ***** End of dynamic_pivot.sql *****
EXPLANATION:
The basic pivot assumes you know the number of distinct jobs,
and the name of each one. If you do, then writing a pivot query
is simply a matter of writing the correct number of ", COUNT ... AS ..."\
lines, with the name entered in two places on each one. That is easily
done by a preliminary query, which uses SPOOL to write a sub-script
(called dynamic_pivot_subscript.sql in this example).
The main script invokes this sub-script at the proper point.
In practice, .SQL scripts usually contain one or more complete
statements, but there's nothing that says they have to.
This one contains just a fragment from the middle of a SELECT statement.
Before creating the sub-script, turn off SQL*Plus features that are
designed to help humans read the output (such as headings and
feedback messages like "7 rows selected.", since we do not want these
to appear in the sub-script.
Turn these features on again before running the main query.
*/ -
How to produce dynamic cross-tab query result on this data ?
Hi gurus,
I have sales (simplified) sales data as below :
create table sales_summ (area_code varchar2(3), sales_amt number, product varchar2(10) ) ;
insert into sales_summ values ('A01', 100, 'P01');
insert into sales_summ values ('A02', 200, 'P01');
insert into sales_summ values ('B01', 300, 'P02');
insert into sales_summ values ('A01', 400, 'P02');
insert into sales_summ values ('A02', 500, 'P01');
insert into sales_summ values ('A03', 600, 'P01');
insert into sales_summ values ('A01', 700, 'P02');
insert into sales_summ values ('A02', 800, 'P02');
insert into sales_summ values ('A03', 900, 'P01');
And I want to produce a cross-tab sales summary like below :
Product A01 A02 A03 B01
P01 100 700 1500 0
P02 1100 800 0 300
How is the query ?
Thank you for your help,
xtantoSearch this forum for "pivot". Plenty of examples.
Regards,
Rob. -
Post Author: ivanl
CA Forum: Formula
Hi,
Using XI and win XP.
I have been using excel to get the info I need, but thought it must be possible to do it right in the cross tab. I need two different cross tabs, and do not know how to do the following.
The fields I have in the dataset include:
- product.type (different products and one field "product.type = 'customer' that is the customers)
- product.balance (balance of each product for each customer)
- formula for age segmentation
What I need to input into the cross tab is to have the segmentation across the top, products for the rows and as the summary:
1) penetration rate (i.e. count of product types divided by # of customers which is product.type = customer)
2) $ per customer (product balance divided by customers)
3) $ per product (product balance divided by # of products)
Help would be awesome. I have no idea how to do this in Crystal
To date, I have set up a cross tab with segment across top, products down the rows, and as a summary using count products and sum of balances. I would input this into excel and do the calculations.
IvanHi, this may help,
http://www.chelseatech.co.nz/pubs.htm
Look down on the right side, you should see
Sample Report Files
Sales Calendar
Calendar Report
Running Totals in a Crosstab
Wrapping Crosstab
PDF Drill Down
Crosstab calculations
Hierarchical Summary in a formula
You can download an example of Crosstab Calulations from this site.
They have some newsletters that also contain CR hints. -
Hi all
I need an help
SELECT * FROM TABLE_A
ID SCHEDULED MARK
1 01/18/2011 T01
2 01/18/2011 T02
3 01/18/2011 T03
4 01/19/2011 T04
5 01/20/2011 T05 I want Results like below for folllowing query
SELECT SCHEDULED,MARK FROM TABLE_A
WHERE SCHEDULED BETWEEN TO_CHAR(SYSDATE,'MM/DD/YYYY') AND TO_CHAR(SYSDATE +1,'MM/DD/YYYY')
1/18/2010 1/19/2011
T01 T04
T02
T03
CREATE TABLE "TABLE_A"
( "ID" NUMBER,
"SCHEDULED" DATE,
"MARK" VARCHAR2(50)
insert into table_a values(1, '01/18/2011', 'T01');
insert into table_a values( 2, ' 01/18/2011', 'T02');
insert into table_a values( 3, ' 01/18/2011', 'T03');
insert into table_a values( 4, ' 01/19/2011', 'T04');
commit;Thanks for your helpuser1849 wrote:
Hi all
I need an help
SELECT * FROM TABLE_A
ID SCHEDULED MARK
1 01/18/2011 T01
2 01/18/2011 T02
3 01/18/2011 T03
4 01/19/2011 T04
5 01/20/2011 T05 I want Results like below for folllowing query
SELECT SCHEDULED,MARK FROM TABLE_A
WHERE SCHEDULED BETWEEN TO_CHAR(SYSDATE,'MM/DD/YYYY') AND TO_CHAR(SYSDATE +1,'MM/DD/YYYY')
1/18/2010 1/19/2011
T01 T04
T02
T03
CREATE TABLE "TABLE_A"
( "ID" NUMBER,
"SCHEDULED" DATE,
"MARK" VARCHAR2(50)
insert into table_a values(1, '01/18/2011', 'T01');
insert into table_a values( 2, ' 01/18/2011', 'T02');
insert into table_a values( 3, ' 01/18/2011', 'T03');
insert into table_a values( 4, ' 01/19/2011', 'T04');
commit;Thanks for your helphttp://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:766825833740 -
I have a question about a correlation table and getting the results whether it is there or not. I've done this in SQL Server's product but haven't had success transferring it to ORACLE. Here is the situation:
I have a table of visitors, a table of visitor attributes and a table correlating the visitor to the attributes. The visitor doesn't need to have all of the attributes. In SQL Server I use a left outer join and join on the visitor attribute value (the correlation table) one time for each attribute in the visitor attribute table. The result should be a query that returns a recordset of all visitors with all attributes as the columns with NULL where there is no attribute value and (obviously) a value where there is one. Any help would be greatly appreciated. (Please CC responses to [email protected]).
Here is the query that I use in SQL server:
SELECT
V.id id,
V.firstvisit firstvisit,
V.lastvisit lastvisit,
V.visitcount visitcount,
VAV_PHON.ATTRIBUTEVALUE Phone,
VAV_STAT.ATTRIBUTEVALUE State,
VAV_CITY.ATTRIBUTEVALUE City,
VAV_ADDR.ATTRIBUTEVALUE Address,
VAV_LAST.ATTRIBUTEVALUE Last_Name,
VAV_FIRS.ATTRIBUTEVALUE First_Name
FROM WT_TEST3.DBO.TBL_VISITOR V
LEFT OUTER JOIN WT_TEST3.DBO.TBL_VISITORATRVAL VAV_PHON ON
(VAV_PHON.VISITOR_ID = V.ID AND VAV_PHON.ATTRIBUTE_ID = 12)
LEFT OUTER JOIN WT_TEST3.DBO.TBL_VISITORATRVAL VAV_STAT ON
(VAV_STAT.VISITOR_ID = V.ID AND VAV_STAT.ATTRIBUTE_ID = 11)
LEFT OUTER JOIN WT_TEST3.DBO.TBL_VISITORATRVAL VAV_CITY ON
(VAV_CITY.VISITOR_ID = V.ID AND VAV_CITY.ATTRIBUTE_ID = 10)
LEFT OUTER JOIN WT_TEST3.DBO.TBL_VISITORATRVAL VAV_ADDR ON
(VAV_ADDR.VISITOR_ID = V.ID AND VAV_ADDR.ATTRIBUTE_ID = 9)
LEFT OUTER JOIN WT_TEST3.DBO.TBL_VISITORATRVAL VAV_LAST ON
(VAV_LAST.VISITOR_ID = V.ID AND VAV_LAST.ATTRIBUTE_ID = 8)
LEFT OUTER JOIN WT_TEST3.DBO.TBL_VISITORATRVAL VAV_FIRS ON
(VAV_FIRS.VISITOR_ID = V.ID AND VAV_FIRS.ATTRIBUTE_ID = 7)
nullHi David,
the syntax in Oracle is:
SELECT
V.id id,
V.firstvisit firstvisit,
V.lastvisit lastvisit,
V.visitcount visitcount,
VAV_PHON.ATTRIBUTEVALUE Phone,
VAV_STAT.ATTRIBUTEVALUE State,
VAV_CITY.ATTRIBUTEVALUE City,
VAV_ADDR.ATTRIBUTEVALUE Address,
VAV_LAST.ATTRIBUTEVALUE Last_Name,
VAV_FIRS.ATTRIBUTEVALUE First_Name
FROM dbo.tbl_visitor v ,
dbo.TBL_VISITORATRVAL VAV_PHON,
dbo.TBL_VISITORATRVAL VAV_STAT,
dbo.TBL_VISITORATRVAL VAV_CITY,
dbo.TBL_VISITORATRVAL VAV_ADDR,
dbo.TBL_VISITORATRVAL VAV_LAST,
dbo.TBL_VISITORATRVAL VAV_FIRS
WHERE vav_phon.visitor_id (+)= v.id
AND vav_phon.attribute_id (+)= 12
AND vav_stat.visitor_id (+)= v.id
AND vav_stat.attribute_id (+)= 11
AND vav_city.visitor_id (+)= v.id
AND vav_city.attribute_id (+)= 10
AND vav_addr.visitor_id (+)= v.id
AND vav_addr.attribute_id (+)= 9
AND vav_last.visitor_id (+)= v.id
AND vav_last.attribute_id (+)= 8
AND vav_firs.visitor_id (+)= v.id
AND vav_firs.attribute_id (+)= 11The outer join operator is (+).
Bye Max
null -
how do you do the equivilent in a webi report?
I dont think case statements are supported
e.g.
Code:
SELECT
SUM(CASE WHEN purchase_date BETWEEN '2004-08-01' and '2004-08-31' THEN amount ELSE 0 END) As m2004_08,
SUM(CASE WHEN purchase_date BETWEEN '2004-09-01' and '2004-09-30' THEN amount ELSE 0 END) As m2004_09,
SUM(CASE WHEN purchase_date BETWEEN '2004-10-01' and '2004-10-31' THEN amount ELSE 0 END) As m2004_10
FROM purchasesyour split logic sounds like a great idea Dave thanks
I am trying to produce this statement:
SUM(case when mks_clienttype ='C' and mks_reason4fail in ("",'pri record found') then clients end) as Client_email
variable clientTypeFlag
code =If([Mks Clienttype] = "C") Then 1 Else 0
variable reason4failFlag1
code =If([Mks Reason4fail(trim)] = "pri record found" Or [Mks Reason4fail(trim)] = "") Then 1 Else 0
variable clientEmail
code ?
how to actually get the sum of both clientTypeFlag and reason4failFlag1? I am trying to figure it out with no luck I have tried this:
variable: ClientEmail1
code: =Sum([clientTypeFlag]) Where ([clientTypeFlag] = 1)
variable: ClientEmail2
code: =Sum([clientTypeFlag]) Where ([reason4failFlag1] = 1)
variable: clientEmail
code: =[ClientEmail1] + [ClientEmail2]
want the end result to look like this:
Name | clientemail
john | 5
bob | 3
jo | 2
Edited by: Dennis Alishah on Sep 21, 2010 5:58 AM -
Not sure how to do this. I have a table with contents as
empid
empnm
office
phone
and another table with
empid
workdt
notin
I need to display the data such as
empid empnm office phone 1/1/12 1/2/12 1/3/12 1/4/12 1/5/12 1/6/12 1/7/12
123 joe 123 x x x
467 sam 333
777 bill 444 x x
The data in the employee file looks like this
empid empnm office phone
123 joe 123
467 sam 333
777 bill 444
The data in the workdates file looks like this
empid workdt notin
123 1/1/12 x
123 1/2/12
123 1/3/12 x
123 1/4/12 x
123 1/5/12
123 1/6/12
123 1/7/12
467 1/1/12
467 1/2/12
467 1/3/12
467 1/4/12
467 1/5/12
467 1/6/12
467 1/7/12
777 1/1/12
777 1/2/12 x
777 1/3/12
777 1/4/12
777 1/5/12 x
777 1/6/12
777 1/7/12Hi,
There are more different options but I show two below:
with empdef as
select 123 empid, 'Joe' empnm, '123' office, cast(null as varchar2(10)) phone from dual union all
select 467, 'Sam', '333', null from dual union all
select 777, 'Bill', '444', null from dual
,workdata as
select 123 empid, to_date('01-JAN-12', 'dd-mon-yy') workdt, 'X' notin from dual union all
select 123, to_date('02-JAN-12', 'dd-mon-yy'),null from dual union all
select 123, to_date('03-JAN-12', 'dd-mon-yy'),'X' from dual union all
select 123, to_date('04-JAN-12', 'dd-mon-yy'),'X' from dual union all
select 123, to_date('05-JAN-12', 'dd-mon-yy'),null from dual union all
select 123, to_date('06-JAN-12', 'dd-mon-yy'),null from dual union all
select 123, to_date('07-JAN-12', 'dd-mon-yy'),null from dual union all
select 467, to_date('01-JAN-12', 'dd-mon-yy'),null from dual union all
select 467, to_date('02-JAN-12', 'dd-mon-yy'),null from dual union all
select 467, to_date('03-JAN-12', 'dd-mon-yy'),null from dual union all
select 467, to_date('04-JAN-12', 'dd-mon-yy'),null from dual union all
select 467, to_date('05-JAN-12', 'dd-mon-yy'),null from dual union all
select 467, to_date('06-JAN-12', 'dd-mon-yy'),null from dual union all
select 467, to_date('07-JAN-12', 'dd-mon-yy'),null from dual union all
select 777, to_date('01-JAN-12', 'dd-mon-yy'),null from dual union all
select 777, to_date('02-JAN-12', 'dd-mon-yy'),'X' from dual union all
select 777, to_date('03-JAN-12', 'dd-mon-yy'),null from dual union all
select 777, to_date('04-JAN-12', 'dd-mon-yy'),null from dual union all
select 777, to_date('05-JAN-12', 'dd-mon-yy'),'X' from dual union all
select 777, to_date('06-JAN-12', 'dd-mon-yy'),null from dual union all
select 777, to_date('07-JAN-12', 'dd-mon-yy'),null from dual
select
e.empid
,e.empnm
,e.office
,e.phone
,max(case when w.workdt = to_date('01-01-2012', 'dd-mm-yyyy') then notin else null end) "1/1/12"
,max(case when w.workdt = to_date('02-01-2012', 'dd-mm-yyyy') then notin else null end) "1/2/12"
,max(case when w.workdt = to_date('03-01-2012', 'dd-mm-yyyy') then notin else null end) "1/3/12"
,max(case when w.workdt = to_date('04-01-2012', 'dd-mm-yyyy') then notin else null end) "1/4/12"
,max(case when w.workdt = to_date('05-01-2012', 'dd-mm-yyyy') then notin else null end) "1/5/12"
,max(case when w.workdt = to_date('06-01-2012', 'dd-mm-yyyy') then notin else null end) "1/6/12"
,max(case when w.workdt = to_date('07-01-2012', 'dd-mm-yyyy') then notin else null end) "1/7/12"
from
empdef e join
workdata w on (e.empid = w.empid)
group by
e.empid
,e.empnm
,e.office
,e.phone
order by
e.empid
EMPID EMPNM OFFICE PHONE 1/1/12 1/2/12 1/3/12 1/4/12 1/5/12 1/6/12 1/7/12
123 Joe 123 X X X
467 Sam 333
777 Bill 444 X X or with the pivot clause:
with empdef as
select 123 empid, 'Joe' empnm, '123' office, cast(null as varchar2(10)) phone from dual union all
select 467, 'Sam', '333', null from dual union all
select 777, 'Bill', '444', null from dual
,workdata as
select 123 empid, to_date('01-JAN-12', 'dd-mon-yy') workdt, 'X' notin from dual union all
select 123, to_date('02-JAN-12', 'dd-mon-yy'),null from dual union all
select 123, to_date('03-JAN-12', 'dd-mon-yy'),'X' from dual union all
select 123, to_date('04-JAN-12', 'dd-mon-yy'),'X' from dual union all
select 123, to_date('05-JAN-12', 'dd-mon-yy'),null from dual union all
select 123, to_date('06-JAN-12', 'dd-mon-yy'),null from dual union all
select 123, to_date('07-JAN-12', 'dd-mon-yy'),null from dual union all
select 467, to_date('01-JAN-12', 'dd-mon-yy'),null from dual union all
select 467, to_date('02-JAN-12', 'dd-mon-yy'),null from dual union all
select 467, to_date('03-JAN-12', 'dd-mon-yy'),null from dual union all
select 467, to_date('04-JAN-12', 'dd-mon-yy'),null from dual union all
select 467, to_date('05-JAN-12', 'dd-mon-yy'),null from dual union all
select 467, to_date('06-JAN-12', 'dd-mon-yy'),null from dual union all
select 467, to_date('07-JAN-12', 'dd-mon-yy'),null from dual union all
select 777, to_date('01-JAN-12', 'dd-mon-yy'),null from dual union all
select 777, to_date('02-JAN-12', 'dd-mon-yy'),'X' from dual union all
select 777, to_date('03-JAN-12', 'dd-mon-yy'),null from dual union all
select 777, to_date('04-JAN-12', 'dd-mon-yy'),null from dual union all
select 777, to_date('05-JAN-12', 'dd-mon-yy'),'X' from dual union all
select 777, to_date('06-JAN-12', 'dd-mon-yy'),null from dual union all
select 777, to_date('07-JAN-12', 'dd-mon-yy'),null from dual
select
from
empdef e join
workdata w using (empid)
pivot(max(notin) for workdt in (to_date( '01-01-2012', 'mm-dd-yyyy') as "1/1/12"
,to_date( '01-02-2012', 'mm-dd-yyyy') as "1/2/12"
,to_date( '01-03-2012', 'mm-dd-yyyy') as "1/3/12"
,to_date( '01-04-2012', 'mm-dd-yyyy') as "1/4/12"
,to_date( '01-05-2012', 'mm-dd-yyyy') as "1/5/12"
,to_date( '01-06-2012', 'mm-dd-yyyy') as "1/6/12"
,to_date( '01-07-2012', 'mm-dd-yyyy') as "1/7/12"
EMPID EMPNM OFFICE PHONE 1/1/12 1/2/12 1/3/12 1/4/12 1/5/12 1/6/12 1/7/12
467 Sam 333
123 Joe 123 X X X
777 Bill 444 X X Regards,
Peter -
I have a crosstab report set up like this:
Department x y Total
Days, ALOS (calculated) Days, ALOS (calculated) Days, Enctrs
Product
x
y
z
I need to take total encounters / days per dept to get the ALOS. In the grand total of the report I get the correct amount of encounters to use. Is there a way to divide days by department by total encounters for all departments?Please re-post if this is still an issue or purchase a case and have a dedicated support engineer work with you directly:
http://store.businessobjects.com/store/bobjamer/DisplayProductByTypePage&parentCategoryID=&categoryID=11522300?resid=-Z5tUwoHAiwAAA8@NLgAAAAS&rests=1254701640551 -
CROSS TAB PRINTING IN PDF PROBLEM
Post Author: peachpx
CA Forum: General
Hi,
My report uses a Cross Tab query with multiple lines for each value. Originally, I only get one line for Total In. I modified Total In to include three lines Total Into Final, Total Into Initial and Total Out. It displays fine in the report, but when I try to print from the server it opens PDF file with only one line present Total Into Final and the other two lines are cut off. Is this a BUG in CRXII or is this can be fixed with correct formatting?
Please help!Hi,
cross tab is a diagonal report , u have to make query in such a way so that it returns the all field in row and columns way i.e in diagonal form .
U have to fetch total in same manner
Rgds,
Premraj -
Hi peers,
i am really stack on how to do the following using Oracle SQL. I want to build a cross tab query where my columns are current year& next year months ( i.e 24 columns will be built)..
any thoughts on how to do that ?
thank youHi sb92075 ,
i got it i am trying to see how can i tweak it lit bit..
in my case i have a cross tab query were values in my SELECT statment are different , example :
SELECT *
FROM
SELECT
PROJECTNAME,
PROJECTID
SUM(DECODE(to_char(IM_MONTH,'mm-yyyy'), to_char(add_months(sysdate,1),'mm-yyyy'), SALE,0)) as '01-2011'
,SUM(DECODE(to_char(IM_MONTH,'mm-yyyy'), to_char(add_months(sysdate,2),'mm-yyyy'), SALE,0)) as '02-2011'
,SUM(DECODE(to_char(IM_MONTH,'mm-yyyy'), to_char(add_months(sysdate,3),'mm-yyyy'), SALE,0)) as '03-2011'
FROM TABLE
what i am looking for is :
1-
to have (sysdate,1) replaced by the 1st month of the current year 'JAN-2011'
same thing for (sysdate,2) replaced by the 1st month of the current year 'FEB-2011'
and so on until the last month of the next year . In total 24 monthss
2-
for each select item , i need to have the column called by that month name i.e :
SUM(DECODE(to_char(IM_MONTH,'mm-yyyy'), to_char(add_months(month1),'mm-yyyy'), SALE,0)) as 'month1'
SUM(DECODE(to_char(IM_MONTH,'mm-yyyy'), to_char(add_months(month2),'mm-yyyy'), SALE,0)) as 'month2'
any thoughts ?
thanks -
Cross-tab style queries...
As you may have guessed, I'm new to the Oracle flavour of SQL.
I'm trying to create a cross-tab query, do any of you guys know a good way of doing this?
Thanks very much.You can do like this. Its an ex. you can extend as you need
SELECT job,
sum(decode(deptno,10,sal)) DEPT10,
sum(decode(deptno,20,sal)) DEPT20,
sum(decode(deptno,30,sal)) DEPT30,
sum(decode(deptno,40,sal)) DEPT40
FROM scott.emp
GROUP BY job
Hari -
why access such a small database can provide cross tab query
facility and not by oracle, if somebody knows the real and
flexible method of doing this plz be informs us.I will be highly
oblized
thanksI came across this example recently on the site:
http://www.onwe.co.za/frank/faqscrpt.htm
I believe this is what you're looking for...
rem -------------------------------------------------------------
rem UPDATED VERSION
rem Filename: matrix.sql
rem Purpose: Example of a CROSS MATRIX report implemented
using
rem standard SQL.
rem Date: 12-Feb-2000
rem Author: Frank Naude ([email protected])
rem
rem Updated By Mahesh Pednekar. ([email protected])
rem Description Removed the Main query because the sub query
itself
rem will full fill the requirement.
rem -------------------------------------------------------------
SELECT job,
sum(decode(deptno,10,sal)) DEPT10,
sum(decode(deptno,20,sal)) DEPT20,
sum(decode(deptno,30,sal)) DEPT30,
sum(decode(deptno,40,sal)) DEPT40
FROM scott.emp
GROUP BY job
-- Sample output:
-- JOB DEPT10 DEPT20 DEPT30 DEPT40
-- ANALYST 6000
-- CLERK 1300 1900 950
-- MANAGER 2450 2975 2850
-- PRESIDENT 5000
-- SALESMAN 5600 -
Cross tab - to summarize number of rows
Hi Everyone,
a) I notice that if I use the count of Final Grade field, some students have more than one row for that class.
So the count = 2.
b) I created a calc: If Final Grade Count > 1, then set calc to 1.
c) then I duplicated query as cross tab
there are 2 datapoint fields: final grade count and Calc_RevisedCount
d) delete final grade count and left Calc_RevisedCount
e) dragged Course name to left,
Final_Grade on top
Calc_RevisedCount is the datapoint
f) problem is that the calc_REvisedCount is NOT tabulating/summarizing
the boxes are being populated with 1's
Is there a better approach, or do you have any advice? thx in advance, sandraHi Rod,
tx for writing...
a) Do you mean I should create a calc?
b) Do I use plain Count_distinct (or the version with partition)
c) I can use a calc as a data point in a cross tab query?
i'm going home for the day.... tx soooo much for writing back..... sandra -
Creation of cross tab report in Bw 3.5 Query designer
Hi,
Please tell me the procedure to create cross tab report in BW 3.5 Query designer. Kindly reply as early as possible.
Regards,
Hari Phrased B.Hi,
What exactly do you mean by "cross tab report"...do you mean a web report with different tabs?
Maybe you are looking for
-
I often use the space bar to page down in web pages rather than scrolling with the mouse or arrow keys, but in the last few months I've encountered a number of pages that don't seem to allow this browser feature to work. For instance, space bar doesn
-
How to install Epson ICC profiles using Photoshop CC?
How to install Epson ICC profiles ussing Photoshop CC on Mac?
-
How to change the colors in Keynote 6.1 globally using the xml presentation file?
Hi , When I used keynote 5.3 in the "show package contents" I could find an Index.apxl.gz file. With that XML like file, I changed the color of a scheme globaly by replacing the color that I had with another one. However in new Keynote 6.1 there is n
-
Need for an info for the n275gtx's!!
I'm new on this forum, and because I need an info that I could not find anywhere else, I hope to get it from you guys. The word is on the n275gtx lightning and the n275gtx twin frozr OC'd. I LOVE to get me one of these babies, but... In Macedonia (wh
-
Hi all Can anyone plz provide me a good technical documentation(except the Config guide and Installation guide from SAP)on mySAP CRM E-service? Thanks and regards Debolina