Query to display Standar Routings and Operations!
Hello again SAP gurus...
I'm trying to create a query to show Standard Routing and Operations.
For this I am using PLKO -> PLAS -> PLPO. Select parameters are PLKO-WERKS only.
The system don't show any information!!!
Can someone help on this?
Thanks in advance.
Adelmo Silva
Hi,
pls try connect below
PLKO-WERKS
PLKO-PLNNR = PLAS-PLNNR and
PLKO-PLNAL = PLAS-PLNAL
PLAS-PLNNR = PLPO-PLNNR and
PLAS-PLNKN = PLPO-PLNKN
I hope this will work fine
Regards,
Sankaran
Similar Messages
-
Query to display BOMs Header and Item
Hello SAP gurus
I am trying to create a query to display BOMs with header and item. For that I am using tables MAST, STKO and STPO.
The table join is:
MAST -> STKO -> STPO
MAST - WERKS, STLNR and STLAL
STKO - STLNR and STPOZ
The system dont show anything...
Can someone help me?
Thanks in advance.
Adelmo SilvaYes, it works but...
If I have 2 alternatives, the system show everything even if i select alternative 1 or 2.
I am missing something... because system is showing all alternatives...
System is showing something like this:
Material BOM AltBOM BOM St Item ICt Component Valid from Quantity Un
726121012 00131075 1 01 0010 L 109219 17-12-2007 0,200 KG
726121012 00131075 1 01 0020 L 109230 17-12-2007 0,003 KG
726121012 00131075 1 01 0030 L 109232 17-12-2007 1,166 M2
726121012 00131075 1 01 0040 L 726004012 17-12-2007 0,120 M3
726121012 00131075 1 01 0010 L 109526 17-12-2007 0,200 KG
726121012 00131075 1 01 0020 L 109232 17-12-2007 1,166 M2
726121012 00131075 1 01 0030 L 726004012 17-12-2007 0,120 M3
Edited by: Adelmo Silva on Jan 9, 2008 9:07 AM -
Query to display data monthwise and calculate total for first 12 months
Hi All,
I have a query that displays forecast data monthwise.
This has been achieved by adding 0CALMONTH on top of key figure structure.
Eg: -
APR 2011 MAY 2011 JUNE 2011 ....... NOV 2013
Forecast Forecast Forecast Forecast
PRODUCT 1 10 15 20 25
Now there is a requirement to include new column that displays total of first 12 months data only.
How can I achieve this without repeating the total value for every value of 0CALMONTH?
Eg: -
APR 2011 MAY 2011 JUNE 2011 ....... MAR 2011 TOTAL of APR 2012 ....... NOV 2013
Forecast Forecast Forecast Forecast 12 months Forecast Forecast
PRODUCT 1 10 15 20 25 300 10 30
Any inputs will be appreciated.
Thanks & Regards
ManishaHi,
As far as i understand your requirement is to make a new keyfigure which has to be total of 12 months and that keyfigure should not get splitted based on calmonth which you have kept above the key figure structure in columns.
I dont think it will be possible to achieve it that way.You need to make a fixed structure which will dispaly data for say next 12 months or whatever your user requirement is and you need to make a seperate keyfigure with month offsets and then you can make a seperate total keyfigure(of 12 months).
With the help of text variable type replacement path you can get the seperate month names for all your forecasted keyfigures.
I had the same requirement but my user wanted to see the next six months data only so i made it with the help of month offsets.
If you get any other work around to achieve your requirement then please do share the solution with us.
Hope it helps.
Regards,
AL
Edited by: AL1112 on Sep 6, 2011 9:34 AM -
Query to display PO number and wip_entity_name
hi
i have this requirement as to add the following to an existing query (based on standard tables)
SELECT
MMT.INVENTORY_ITEM_ID DT_INVENTORY_ITEM_ID
, MMT.ORGANIZATION_ID DT_ORGANIZATION_ID
, MMT.TRANSACTION_DATE DT_TRANSACTION_DATE
, MMT.TRANSACTION_SOURCE_ID DT_VOUCHER_NO
, NVL(MMT.TRANSACTION_COST,0) DT_TRANSACTION_COST
, MTT.TRANSACTION_TYPE_NAME DT_TRANSACTION_TYPE_NAME
, NVL(MMT.NEW_COST,0) DT_NEW_COST
, DECODE((MMT.PRIMARY_QUANTITY/ABS(MMT.PRIMARY_QUANTITY)),1,MMT.PRIMARY_QUANTITY,0)
DT_QTY_IN
, DECODE((MMT.PRIMARY_QUANTITY/ABS(MMT.PRIMARY_QUANTITY)),-1,MMT.PRIMARY_QUANTITY,0) * -1
DT_QTY_OUT
FROM
MTL_MATERIAL_TRANSACTIONS MMT
, MTL_TRANSACTION_TYPES MTT
WHERE
MMT.PRIMARY_QUANTITY <> 0
AND MMT.TRANSACTION_TYPE_ID NOT IN (101,120,80)
/* ABOVE CONDITION TO EXCLUDE OPENING BALANCE TRANSACTIONS
AND AVERAGE COST UPDATE
AND MMT.SUBINVENTORY_CODE <> 'OM'
AND MMT.TRANSACTION_TYPE_ID = MTT.TRANSACTION_TYPE_ID
AND MMT.TRANSACTION_DATE BETWEEN :P_START_DATE AND :P_END_DATEwhenever the MTL_TRANSACTION_TYPES MTT.TRANSACTION_TYPE_NAME='PO Receipt' then display the PO number
similarly WHEN MTL_TRANSACTION_TYPES MTT.TRANSACTION_TYPE_NAME= Wip Component Issue then display wip_entity name
P_START_DATE AND :P_END_DATE i have put is 01-jan-2011 and 28-feb-2011
once i add these conditions to the query ,the query displays less amount of rows ie 2014 rows whereas the first query used to return 2357 rows
this is the modified query
SELECT
MMT.INVENTORY_ITEM_ID DT_INVENTORY_ITEM_ID,
case when MTT.TRANSACTION_TYPE_NAME='WIP component issue' then wip.WIP_ENTITY_NAME
when MTT.TRANSACTION_TYPE_NAME='WIP Component Return' then wip.WIP_ENTITY_NAME
when MTT.TRANSACTION_TYPE_NAME='NP-Material Request' then wip.WIP_ENTITY_NAME
end job_number
, MMT.ORGANIZATION_ID DT_ORGANIZATION_ID
, MMT.TRANSACTION_DATE DT_TRANSACTION_DATE
, MMT.TRANSACTION_SOURCE_ID DT_VOUCHER_NO
, NVL(MMT.TRANSACTION_COST,0) DT_TRANSACTION_COST
, MTT.TRANSACTION_TYPE_NAME DT_TRANSACTION_TYPE_NAME
, NVL(MMT.NEW_COST,0) DT_NEW_COST
, DECODE((MMT.PRIMARY_QUANTITY/ABS(MMT.PRIMARY_QUANTITY)),1,MMT.PRIMARY_QUANTITY,0)
DT_QTY_IN
, DECODE((MMT.PRIMARY_QUANTITY/ABS(MMT.PRIMARY_QUANTITY)),-1,MMT.PRIMARY_QUANTITY,0) * -1
DT_QTY_OUT
FROM
MTL_MATERIAL_TRANSACTIONS MMT
, MTL_TRANSACTION_TYPES MTT
,WIP_ENTITIES WIP
WHERE
MMT.PRIMARY_QUANTITY <> 0
AND MMT.TRANSACTION_TYPE_ID NOT IN (101,120,80)
AND MMT.TRANSACTION_SOURCE_ID = WIP.WIP_ENTITY_ID(+)
/* ABOVE CONDITION TO EXCLUDE OPENING BALANCE TRANSACTIONS
AND AVERAGE COST UPDATE
AND MMT.SUBINVENTORY_CODE <> 'OM'
AND MMT.TRANSACTION_TYPE_ID = MTT.TRANSACTION_TYPE_ID
AND MMT.TRANSACTION_DATE BETWEEN :P_START_DATE AND :P_END_DATE
union
SELECT
MMT.INVENTORY_ITEM_ID DT_INVENTORY_ITEM_ID,
case
when MTT.TRANSACTION_TYPE_NAME='PO Receipt' then PHA.SEGMENT1 end job_number
, MMT.ORGANIZATION_ID DT_ORGANIZATION_ID
, MMT.TRANSACTION_DATE DT_TRANSACTION_DATE
, MMT.TRANSACTION_SOURCE_ID DT_VOUCHER_NO
, NVL(MMT.TRANSACTION_COST,0) DT_TRANSACTION_COST
, MTT.TRANSACTION_TYPE_NAME DT_TRANSACTION_TYPE_NAME
, NVL(MMT.NEW_COST,0) DT_NEW_COST
, DECODE((MMT.PRIMARY_QUANTITY/ABS(MMT.PRIMARY_QUANTITY)),1,MMT.PRIMARY_QUANTITY,0)
DT_QTY_IN
, DECODE((MMT.PRIMARY_QUANTITY/ABS(MMT.PRIMARY_QUANTITY)),-1,MMT.PRIMARY_QUANTITY,0) * -1
DT_QTY_OUT
FROM
MTL_MATERIAL_TRANSACTIONS MMT
, MTL_TRANSACTION_TYPES MTT
,PO_HEADERS_ALL PHA
,PO_LINES_ALL POL
WHERE
MMT.PRIMARY_QUANTITY <> 0
AND MMT.TRANSACTION_TYPE_ID NOT IN (101,120,80)
AND MMT.TRANSACTION_SOURCE_ID=POL.PO_LINE_ID
AND PHA.PO_HEADER_ID=POL.PO_LINE_ID
/* ABOVE CONDITION TO EXCLUDE OPENING BALANCE TRANSACTIONS
AND AVERAGE COST UPDATE
AND MMT.SUBINVENTORY_CODE <> 'OM'
AND MMT.TRANSACTION_TYPE_ID = MTT.TRANSACTION_TYPE_ID
AND MMT.TRANSACTION_DATE BETWEEN :P_START_DATE AND :P_END_DATEkindly guide
thanking in advanceHi,
There could be nothing wrong in your Query, as all the WiP Assembly completions, WIP Negative Component Issue ,WIP Negative Component Return etc transaction types could be there in the Mat txns table for this period. Please check them -
BEx Query Formating - Displaying both Sum and Average in the same report
Hi everybody,
I need to create a BW report in the below format,
Company Code Total Total Average
0001 0002 0003 0004
Doc Type
AV 10 10 10 10 40 10
RV 20 20 20 20 80 20
Getting the report till the 'Total' column is easy but having the 'Total Average' as a separate column is where I am stuck.
Having the company code in the rows, and not clolumns, would have solved the issue but I need to keep the above format. Also I do not want to
see the Total Average for every Company Code, just that of the 'Total'.
In the Query Designer, in the Column section I have first the 'Company Code' and then the 'Count' in a structure, so whatever I add to this structure,
is displayed for each Company Code, that means 2 columns for each Company code. This changes the format.
I cannot use the Cell Definition method here, as then it would be a static structure and the number of Company Codes are not fixed.
It would be great if somebody could provide some suggestions.
Thank you,
AjayHi Suman,
Thanks for the quick reply.
I have tried this, but again this will change the format. With the way you said, I will only get the report in the below 2 formats,
1. Company code in Free Charac, later drill down to Rows,
Doc Type Company Code
AV 0001 10
AV 0002 10
AV 0003 10
AV 0004 10
Total 40
RV 0001 20
RV 0002 20
RV 0003 20
RV 0004 20
Total 80
or 2. Company code in Free Charac, later drill down to Column,
Company Code
0001 0002 0003 0004
Total Total Avg Total Total Avg Total Total Avg Total Total Avg
Doc Type
AV 10 10 10 10 10 10 10 10
RV 20 20 20 20 20 20 20 20
Both the above are different from the format that I need. -
Select query not working with like & and operator
Hi,
The below is the select query which is used to select only the failed rollup jobs from DB table ( background jobs ) the status 'A' which means only the failed roll up jobs.
select jobname status from v_op into table zjob_rollup where jobname like '%ROLLUP%'
or jobname like 'BI_AGGR%'
and status like 'A'.
Right now my internal tables is picking the job name other than status A also.
Can you please help.
Note: Ps consider the performance of select query also.
Thanks,
SivaHi,
select jobname status
from v_op
into table zjob_rollup
where ( jobname like '%ROLLUP%' or jobname like 'BI_AGGR%' )
and status = 'A'. -
Problem in display of char. and key figure for yearly query
Hello all,
I got a query in which i have to do restriction on
Calendar Day/Month in Rows under Material which is a Characteristics
So it should be
PACKAGE QUANTITY
JAN FEB MAR APRIL.......DEC
PACK1
PACK2
PACK3
PACK4 for current year
PACK4 for prior YEar
Now the months display is not pre decided, it can be anything as per the input of user.
So i have to restrict it on Calendar month for Material twice
In current year , just introducing the Interval range variable
In previous year, same restricition with offset -12
Now the problem is while displaying it shows
JAN'06 JAN'07 FEB'06 FEB'07 MAR'06 MAR'07........
PACK1
PACK2
PACK3
PACK4 for current year
PACK4 for prior YEar
Which is not desirable.
I only want value for Jan in one column
and for previous year and current year in different rows thats it.
If i remove Calendar year/month from columns there is no way I CAN DISPLAY MONTHS .
How to achieve this.
Please suggest.Kartikey,
Rusty's suggestion wont work - using two characteristics for year and month will have the same effect as the position you are in at the moment.
ie..
2007 Jan.07 Feb.07 Mar.07 Apr.07
2006 -
Jan 06 Feb 06 Mar 06
If you have the posting period of 01 - 02 - 03 (just the period number only, no year) then your query will display
2007-01-02-03-04
2006-01-02-03-04
Regards
Gill -
Flash files not displaying in Firefox, Safari, and Opera. Most recent Shockwave installed, private browsing active in Firefox? Works perfectly in Chrome and Internet Explorer. HELP!!!!
I suppose it would have helped if you knew what it was supposed to look like! I'm using Shockwave Flash 11.7.700.169 and the version of Firefox I'm on is 20.0
When you see it in Firefox - do the thumbnail populate the grid? See attached populated and un-populated.
Populated grid is with Chrome.
Thanks!
Thanks in advance! -
Select Query using AND operation
Hello,
I am developing RFC which will retrieve some records from SAP HR module table.
Input will be one structure (INPUT_TABLE) containing 4 fields. User may enter values for any fields, and my requirement is to perform a AND operation on those entered fields only. Currently i am writing query as follows :
SELECT DISTINCT apernr aVORNA aNACHN acname a~gbdat FROM
PA0002 as a INTO CORRESPONDING FIELDS OF TABLE Z_PD_TABLE
WHERE apernr = INPUT_TABLE-pernr AND aVNAMC = INPUT_TABLE-VORNA AND aNCHMC = INPUT_TABLE-NACHN AND agbdat = INPUT_TABLE-GBDAT .
If only 2 values are entered by user out of 4 , it will perform AND operation by taking other values as blank or 000000. I want to skip these AND operation on fields which are not entered by user.
Please help for writing query.
Thanks in advance,
PrashantHi,
Create dynamic where condition based upon user input.
Try like this....
IF NOT INPUT_TABLE-pernr IS INITIAL.
CLEAR : lv_pernr_condition.
CONCATENATE 'PERNR' ' = ' '''' INPUT_TABLE-pernr '''' INTO
lv_pernr_condition.
ENDIF.
IF NOT INPUT_TABLE-vnamc IS INITIAL.
CLEAR : lv_vnamc_condition.
CONCATENATE 'VNAMC' ' = ' '''' INPUT_TABLE-vnamc '''' INTO
lv_vnamc_condition.
ENDIF.
IF NOT INPUT_TABLE-vorna IS INITIAL.
CLEAR : lv_vorna_condition.
CONCATENATE 'VORNA' ' = ' '''' INPUT_TABLE-vorna '''' INTO
lv_vorna_condition.
ENDIF.
IF NOT INPUT_TABLE-nchmc IS INITIAL.
CLEAR : lv_nchmc_condition.
CONCATENATE 'NCHMC' ' = ' '''' INPUT_TABLE-nchmc '''' INTO
lv_nchmc_condition.
ENDIF.
IF NOT INPUT_TABLE-gbdat IS INITIAL.
CLEAR : lv_gbdat_condition.
CONCATENATE 'GBDAT' ' = ' '''' INPUT_TABLE-gbdat '''' INTO
lv_gbdat_condition.
ENDIF.
IF NOT lv_pernr_condition IS INITIAL.
CONCATENATE lv_pernr_condition lv_condition
INTO lv_condition SEPARATED BY space.
ENDIF.
IF NOT lv_vnamc_condition IS INITIAL.
IF lv_condition IS INITIAL.
CONCATENATE lv_vnamc_condition lv_condition
INTO lv_condition SEPARATED BY space.
ELSE.
CONCATENATE lv_condition 'AND' lv_vnamc_condition
INTO lv_condition SEPARATED BY space.
ENDIF.
ENDIF.
IF NOT lv_vorna_condition IS INITIAL.
IF lv_condition IS INITIAL.
CONCATENATE lv_vorna_condition lv_condition
INTO lv_condition SEPARATED BY space.
ELSE.
CONCATENATE lv_condition 'AND' lv_vorna_condition
INTO lv_condition SEPARATED BY space.
ENDIF.
ENDIF.
IF NOT lv_nchmc_condition IS INITIAL.
IF lv_condition IS INITIAL.
CONCATENATE lv_nchmc_condition lv_condition
INTO lv_condition SEPARATED BY space.
ELSE.
CONCATENATE lv_condition 'AND' lv_nchmc_condition
INTO lv_condition SEPARATED BY space.
ENDIF.
ENDIF.
IF NOT lv_gbdat_condition IS INITIAL.
IF lv_condition IS INITIAL.
CONCATENATE lv_gbdat_condition lv_condition
INTO lv_condition SEPARATED BY space.
ELSE.
CONCATENATE lv_condition 'AND' lv_gbdat_condition
INTO lv_condition SEPARATED BY space.
ENDIF.
ENDIF.
SELECT DISTINCT pernr VORNA NACHN cname gbdat FROM
PA0002 INTO CORRESPONDING FIELDS OF TABLE Z_PD_TABLE
WHERE lv_condition . " Dynamic where condition
Hope it will helps -
SCCM report query that displays count of cpus per host and if host is physical or virtual
Hello,
I have this query that displays the count of CPUs per host. How can I add a column to show if the host a physical or virtual?
SELECT
DISTINCT(CPU.SystemName0) AS [System Name],
CPU.Manufacturer0 AS Manufacturer,
CPU.Name0 AS Name,
COUNT(CPU.ResourceID) AS [Number of CPUs],
CPU.NumberOfCores0 AS [Number of Cores per CPU],
CPU.NumberOfLogicalProcessors0 AS [Logical CPU Count]
FROM [dbo].[v_GS_PROCESSOR] CPU
GROUP BY
CPU.SystemName0,
CPU.Manufacturer0,
CPU.Name0,
CPU.NumberOfCores0,
CPU.NumberOfLogicalProcessors0I see that you have posted this exact question in another forum for CM12, however this is an CM07 forum.
Are you CM07 or CM12?
If you are CM12, use my answer here.
http://www.systemcentercentral.com/forums-archive/topic/sccm-report-query-for-cpu-cores/
If you are CM07, this is NOT a simple how exactly do you detect that a computer is a VM? You can guess by looking at the manufacturer name but it is only a guess.
Garth Jones | My blogs: Enhansoft and
Old Blog site | Twitter:
@GarthMJ -
I am unable to connect to the web on my desktop with Firefox 8, the program displays but will not connect to the Internet, Other browsers Internet Explorer and Opera do connect on the same machine. McAfee is not blocking it, virus checks detect no virus yet yesterday it worked perfectly
I tried what was suggested by starting in Safe Mode but the problem still exists. I am frustrated as I cannot connect to my Verizon Fios page. I can connect to the Internet with the Firefox Browser and can go to any web site except finding my Verizon Home page.
-
Need help in query to display lot and serial numbers for a Wip Job Component
Hi ALL,
I have a requirement as below.
I need to display lot and serial numbers for a Wip Job Component, i have a xml report in that for each wip job component i need to check whether it is a lot control item or serial control item based on that i need to display some data. so can you please help me to get the query to indentify the lot and serial number for a wip job component.
ThanksThank you for replying Gordon. I did not remember I had asked this before. I no longer have access to the other account.
What I need on the query is that I want a list of items with the on order quantity and when we are expecting this order to be received. The receiving date is based on the PO delivery date. The trick here is that I need to Master sku to show the delivery date of the component sku. In my scenario all components have the same delivery date for the Master sku. If there are mulitple delivery dates because each warehouse is getting them on a different date then I want to get the delivery date for that warehouse.
Let me know if this is possible and if yes please guide towards a query for it.
Thank you. -
How I can change this query, so I can display the name and scores in one r
How I can change this query, so I can add the ID from the table SPRIDEN
as of now is giving me what I want:
1,543 A05 24 A01 24 BAC 24 BAE 24 A02 20 BAM 20in one line but I would like to add the id and name that are stored in the table SPRIDEN
SELECT sortest_pidm,
max(decode(rn,1,sortest_tesc_code)) tesc_code1,
max(decode(rn,1,score)) score1,
max(decode(rn,2,sortest_tesc_code)) tesc_code2,
max(decode(rn,2,score)) score2,
max(decode(rn,3,sortest_tesc_code)) tesc_code3,
max(decode(rn,3,score)) score3,
max(decode(rn,4,sortest_tesc_code)) tesc_code4,
max(decode(rn,4,score)) score4,
max(decode(rn,5,sortest_tesc_code)) tesc_code5,
max(decode(rn,5,score)) score5,
max(decode(rn,6,sortest_tesc_code)) tesc_code6,
max(decode(rn,6,score)) score6
FROM (select sortest_pidm,
sortest_tesc_code,
score,
row_number() over (partition by sortest_pidm order by score desc) rn
FROM (select sortest_pidm,
sortest_tesc_code,
max(sortest_test_score) score
from sortest,SPRIDEN
where
SPRIDEN_pidm =SORTEST_PIDM
AND sortest_tesc_code in ('A01','BAE','A02','BAM','A05','BAC')
and sortest_pidm is not null
GROUP BY sortest_pidm, sortest_tesc_code))
GROUP BY sortest_pidm;
Hi,
That depends on whether spriden_pidm is unique, and on what you want for results.
Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevamnt columns only) for all tables, and the results you want from that data.
If you can illustrate your problem using commonly available tables (such as those in the scott or hr schemas) then you don't have to post any sample data; just post the results you want.
Either way, explain how you get those results from that data.
Always say which version of Oracle you're using.
It looks like you're doing something similiar to the following.
Using the emp and dept tables in the scott schema, produce one row of output per department showing the highest salary in each job, for a given set of jobs:
DEPTNO DNAME LOC JOB_1 SAL_1 JOB_2 SAL_2 JOB_3 SAL_3
20 RESEARCH DALLAS ANALYST 3000 MANAGER 2975 CLERK 1100
10 ACCOUNTING NEW YORK MANAGER 2450 CLERK 1300
30 SALES CHICAGO MANAGER 2850 CLERK 950On each row, the jobs are listed in order by the highest salary.
This seems to be analagous to what you're doing. The roles played by sortest_pidm, sortest_tesc_code and sortest_test_score in your sortest table are played by deptno, job and sal in the emp table. The roles played by spriden_pidm, id and name in your spriden table are played by deptno, dname and loc in the dept table.
It sounds like you already have something like the query below, that produces the correct output, except that it does not include the dname and loc columns from the dept table.
SELECT deptno
, MAX (DECODE (rn, 1, job)) AS job_1
, MAX (DECODE (rn, 1, max_sal)) AS sal_1
, MAX (DECODE (rn, 2, job)) AS job_2
, MAX (DECODE (rn, 2, max_sal)) AS sal_2
, MAX (DECODE (rn, 3, job)) AS job_3
, MAX (DECODE (rn, 3, max_sal)) AS sal_3
FROM (
SELECT deptno
, job
, max_sal
, ROW_NUMBER () OVER ( PARTITION BY deptno
ORDER BY max_sal DESC
) AS rn
FROM (
SELECT e.deptno
, e.job
, MAX (e.sal) AS max_sal
FROM scott.emp e
, scott.dept d
WHERE e.deptno = d.deptno
AND e.job IN ('ANALYST', 'CLERK', 'MANAGER')
GROUP BY e.deptno
, e.job
GROUP BY deptno
;Since dept.deptno is unique, there will only be one dname and one loc for each deptno, so we can change the query by replacing "deptno" with "deptno, dname, loc" throughout the query (except in the join condition, of course):
SELECT deptno, dname, loc -- Changed
, MAX (DECODE (rn, 1, job)) AS job_1
, MAX (DECODE (rn, 1, max_sal)) AS sal_1
, MAX (DECODE (rn, 2, job)) AS job_2
, MAX (DECODE (rn, 2, max_sal)) AS sal_2
, MAX (DECODE (rn, 3, job)) AS job_3
, MAX (DECODE (rn, 3, max_sal)) AS sal_3
FROM (
SELECT deptno, dname, loc -- Changed
, job
, max_sal
, ROW_NUMBER () OVER ( PARTITION BY deptno -- , dname, loc -- Changed
ORDER BY max_sal DESC
) AS rn
FROM (
SELECT e.deptno, d.dname, d.loc -- Changed
, e.job
, MAX (e.sal) AS max_sal
FROM scott.emp e
, scott.dept d
WHERE e.deptno = d.deptno
AND e.job IN ('ANALYST', 'CLERK', 'MANAGER')
GROUP BY e.deptno, d.dname, d.loc -- Changed
, e.job
GROUP BY deptno, dname, loc -- Changed
;Actually, you can keep using just deptno in the analytic PARTITION BY clause. It might be a little more efficient to just use deptno, like I did above, but it won't change the results if you use all 3, if there is only 1 danme and 1 loc per deptno.
By the way, you don't need so many sub-queries. You're using the inner sub-query to compute the MAX, and the outer sub-query to compute rn. Analytic functions are computed after aggregate fucntions, so you can do both in the same sub-query like this:
SELECT deptno, dname, loc
, MAX (DECODE (rn, 1, job)) AS job_1
, MAX (DECODE (rn, 1, max_sal)) AS sal_1
, MAX (DECODE (rn, 2, job)) AS job_2
, MAX (DECODE (rn, 2, max_sal)) AS sal_2
, MAX (DECODE (rn, 3, job)) AS job_3
, MAX (DECODE (rn, 3, max_sal)) AS sal_3
FROM (
SELECT e.deptno, d.dname, d.loc
, e.job
, MAX (e.sal) AS max_sal
, ROW_NUMBER () OVER ( PARTITION BY e.deptno
ORDER BY MAX (sal) DESC
) AS rn
FROM scott.emp e
, scott.dept d
WHERE e.deptno = d.deptno
AND e.job IN ('ANALYST', 'CLERK', 'MANAGER')
GROUP BY e.deptno, d.dname, d.loc
, e.job
GROUP BY deptno, dname, loc
;This will work in Oracle 8.1 and up. In Oracle 11, however, it's better to use the SELECT ... PIVOT feature. -
Query re-write in Desktop and Plus
Under Discoverer Desktop, I am getting very good performance for a particular workbook -- Oracle automatically re-writes the query to go after materialized view, rather than after an original huge table.
But, when I run the exact the same workbook under Discoverer Plus, the query re-write does not happen, and the execution plan is totally different.
When I extract the query from the workbook and run it directly against database via SQL*Plus, the query re-write does happen and performance is excellent.
I am using:
OracleBI Discoverer 10g (9.0.4.00.00)
Oracle Business Intelligence Discoverer Plus 10g (10.1.2.48.18)
Discoverer Model - 10.1.2.48.18
Discoverer Server - 10.1.2.48.18
End User Layer - 5.1.1.0.0.0
End User Layer Library - 10.1.2.48.18
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
Are there any Discoverer’s settings that can prevent query re-write under Discoverer Plus?
Thanks.Do you think this might be related to OracleAS?
This is my current hypothesis, I don't see any other explaination at the moment.
"Discoverer uses its own rewrite system when any of the following is true:
1. The database version is less than 8.1.6
2. The database version is later than 8.1.6 and it is not possible for
Discoverer to create Materialized Views.
The point #2 is applicable to my case.
Marcos, could you please point me to the source of this quotation?
My query is below:
SQL> explain plan for
2 SELECT O100096.LOCAL_DAY,
3 O100088.NETWORK_ABBREVIATION,
4 MAX(O102377.IMPRESSIONS_LIVE)
5 FROM DOMRSCH.DW_NETWORK O100088,
6 DOMRSCH.DW_TIME O100096,
7 DOMRSCH.TELECAST_DEMO_RATING O102377
8 WHERE ((O100096.TIME_KEY = O102377.TIME_KEY) AND
9 (O100088.NETWORK_KEY = O102377.NETWORK_KEY)) AND
10 (O100096.LOCAL_DAY IN (TO_DATE('20060515000000', 'YYYYMMDDHH24MISS'),
11 TO_DATE('20060516000000', 'YYYYMMDDHH24MISS'),
12 TO_DATE('20060522000000', 'YYYYMMDDHH24MISS')))
13 GROUP BY O100096.LOCAL_DAY,
14 O100088.NETWORK_ABBREVIATION
15 ORDER BY MAX(O102377.IMPRESSIONS_LIVE) DESC;
Explained.
SQL>
SQL> select * from table(dbms_xplan.display);
Plan hash value: 2592166193
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 23 | 414 | 8 (13)| 00:00:01 |
| 1 | SORT ORDER BY | | 23 | 414 | 8 (13)| 00:00:01 |
|* 2 | MAT_VIEW REWRITE ACCESS FULL| TELECAST_DEMO_RATING_MW | 23 | 414 | 7 (0)| 00:00 -
Displaying current year and previous year's data.
hi all,
we have fields like doc.no, company code, costcenter, posting date, year etc... in a query.
we are using this query to display data in VC,
how can i display the current year and previous year's data in two different tables using the available fields.
any help will be highly appreciated.
thanks,
RkHi Rk,
You can achieve your requirement using 'Filter' operator. Drag one 'Filter' operator into visual composer story board and drag the output into filter and add condition(Check year=2008) and drag one table from filter. For another table use another filter and change the condition.
Hope it helps...
Regards
Basheer
Maybe you are looking for
-
E61i no longer connects successfully
Hi, I'm having a very frustrating problem with my E61i, which has worked perfectly with Bluetooth File Exchange, Nokia Multimedia transfer etc., but now fails to connect. It seems something is corrupted on the phone such that this no longer works. Re
-
Using a Smart TV with my iMac & Macbook Pro
Im a photographer and just purchased a Samsung Smart TV to use in the studio for client consults to show photo slideshows and sales sessions so basically sharing what is on my iMac/MacBookPro screen on the Smart TV. The TV is connected to the networ
-
How to get message ID's with reference to PO numbers.
Hi experts, There is requirement that we need to resend the messages manually from sproxy for a particular interface, they gave only the PO numbers. How can I check the Message IDs corresponding to the PO numbers? I created a UDMS but we require the
-
Specific driver (tkdpo7k) not working in .exe
Hi, I am currently using the IVIscope driver together with the specific driver tkdpo7k. Running the labVIEW code in the labVIEW IDE has no problem but when I build my code into .exe format and run my code, my code returns something like this The foll
-
Urgent: Some how I deleted the rebate agreements. What is the impact on FI?
Hi Some how i deleted the rebate agreements. Some are in active, hence system generated reversal postings. Pls let me know what is the impact on FI? What steps need to be done. Appreciate your immediate help. Thanks, Gupta.