Formula to select top defect help
My boss want me to design a report that will select the top 2 functional areas that has the most defects per Customer. I'm trying to figure out how to create this report w/o using filtering. I think I would need an formula but dont know how to write it. Can anybody help me? Please see example below.
Data:
Column information
Customers, Functional Area, # of defects
Customer1, Webpage, 30
Customer1, Transfer, 12
Customer1, Reports, 40
Customer1, UI, 29
Customer2, Webpage, 50
Customer2, Transfer, 12
Customer2, Reports, 68
Customer2, UI, 29
Customer3, Webpage, 10
Customer3, Transfer, 12
Customer3, Reports, 40
Customer3 UI, 29
In my report I would like to see the following information displayed.
Customer1, Webpage, 30
Customer1, Reports, 40
Customer2, Webpage, 50
Customer2, Reports, 68
Customer3, Reports, 40
Customer3 UI, 29
Thanks BIPuser for the info. However I'm getting the following error when i try to use the formula:
TOPN(SUM("Projec Dim".Domain by "Defect Facts".Product by "Projec Dim".Project by COUNT("Defect Facts"."Defect ID")), 10 by "Defect Facts"."Functional Area")
[nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <by>: Syntax error [nQSError: 26012] . (HY000)
SQL Issued: SELECT "Defect Facts"."13.2 Requirements", "Defect Facts"."BugDB Component", "Defect Facts"."Functional Area", "Defect Facts"."Reported Release (Base)", "Defect Facts"."Testing Type", "Defect Facts".Product, "Defect Facts".Severity, "Defect Facts".Status, "Defect Facts".Tester, "Defect Facts".Type, "Projec Dim".Domain, "Projec Dim".Project, COUNT("Defect Facts"."Defect ID"), TOPN(SUM("Projec Dim".Domain by "Defect Facts".Product by "Projec Dim".Project by COUNT("Defect Facts"."Defect ID")), 10 by "Defect Facts"."Functional Area"), case WHEN "Defect Facts"."Functional Area" IN ('RFM', 'RFM - Fiscal Management', '0390 Fiscal Managment - RFM') then 'RFM Functional Area' else 'RMS Functional Area' end FROM Defect
OK (Ignore Error)
Please Help
Similar Messages
-
ALTERNATIVE FOR 'SELECT TOP STATEMENT
HI FRIENDS
IF ANY ONE KNOWS HOW TO CONVERT THE SQL STATEMENT GIVEN BELOW PLEASE HELP ME
SELECT TOP 1 CardID FROM EasyRechargeMaster WHERE CardGroup = EasyRecharge.CardGroup
THANKS & REGARDSCheck this query. It should give you desired results....Are you sure about that? Does TOP 1 mean "whatever happens to be the first row fetched"?
-
SELECT TOP 1 .... ORDER BY
Hi,
I have the following statement in SQL SERVER:
SELECT TOP 1 NAME FROM STUDENT ORDER BYGRADE
Now, I am trying to translate it ti ORACLE PLSQL, I came up with this statement:
SELECT NAME FROM STUDENT WHERE ROWNUM=1 ORDER BY GRADE
It doesn't work. I guess ORACLE generates ROWNUM before the ORDER BY operation...
How can I have SELECT TOP N ... ORDER BY ... in Oracle the way that I have it in SQL server?
Any help would be apprecited,
AlanCan you cut and paste exactly what you're doing in a SQL*Plus session? It seems to work for me
SCOTT @ hp92 Local> create table t as select * from all_objects;
Table created.
Elapsed: 00:00:08.40
SCOTT @ hp92 Local> desc t;
Name Null? Type
OWNER NOT NULL VARCHAR2(30)
OBJECT_NAME NOT NULL VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NOT NULL NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(18)
CREATED NOT NULL DATE
LAST_DDL_TIME NOT NULL DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
SCOTT @ hp92 Local> create index idx_t on t( object_id );
Index created.
Elapsed: 00:00:00.78
SCOTT @ hp92 Local> analyze table t compute statistics for all indexed columns;
Table analyzed.
Elapsed: 00:00:00.53
SCOTT @ hp92 Local> set autotrace on;
SCOTT @ hp92 Local> select *
2 from (select * from t order by object_id)
3 where rownum < 2;
OWNER OBJECT_NAME SUBOBJECT_NAME
OBJECT_ID DATA_OBJECT_ID OBJECT_TYPE CREATED LAST_DDL_ TIMESTAMP STATUS T G S
SYS DUAL
222 222 TABLE 12-MAY-02 12-MAY-02 2002-05-12:16:20:50 VALID N N N
Elapsed: 00:00:00.13
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 COUNT (STOPKEY)
2 1 VIEW
3 2 TABLE ACCESS (BY INDEX ROWID) OF 'T'
4 3 INDEX (FULL SCAN) OF 'IDX_T' (NON-UNIQUE)
Statistics
0 recursive calls
0 db block gets
3 consistent gets
1 physical reads
0 redo size
1142 bytes sent via SQL*Net to client
511 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processedJustin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Looking for the oracle equivalent of T-SQL 'SELECT TOP n'
Hi,
I'm looking for the Oracle equivalent of T-SQL 'SELECT TOP n'
and can't find any. There is SAMPLE(n) function but it supposed
to pick up random values and I'm not sure if it's possible to
make it select top values. Please help 8-)
ThanxHi Marina.
Oracle does not have a functionality like SQL Server for TOP
selection. The ROWNUM option should be used with great care and
you may get unreliable results.
Try looking at Metalink
Doc ID: 291065.999
Doc ID: 267329.999
- They discuss this issue, and solutions. -
Hi Guys,
I tried Group By from Select Top 1 Records, As below the script wasn't work.
Please help.
SELECT TOP 1 NR.SHGId, NR.Amount
FROM NEW_DCB_REPORT NR
WHERE NR.SHGId = ND.SHGId
AND NR.ShgMemberId = ND.ShgMemberId
AND NR.LoanNumber = ND.LoanNumber
GROUP BY NR.SHGId,NR.Amount
ORDER BY NR.LedgerNumber DESC
SHGId
SHGMemberId
LoanNumber
Amount
Select Top 1 Row
1028
147852
1
1000
Select Top 1 Row
1028
147853
1
2000
Select Top 1 Row
1028
147854
1
1000
Select Top 1 Row
1028
147855
1
1000
5000
I expected the results are:
SHGId
Amount
1028
5000Yes I did it.
Select SHGId,
SUM(Amount)
amt FROM
SELECT NR.SHGId,
NR.Amount,
, Row_number()
Over(partition
by NR.SHGId,
NR.ShgMemberId , NR.LoanNumber
Order
by NR.LedgerNumber
DESC
) rn
FROM NEW_DCB_REPORT NR
JOIN
NEW_DCB_REPORT ND
ON
NR.SHGId
=
ND.SHGId
AND NR.ShgMemberId
= ND.ShgMemberId
AND NR.LoanNumber
= ND.LoanNumber
) t
Where rn=1
GROUP
BY SHGId
I just changed above the script Partition by add one more column and
[yourNDTable]
Should come NEW_DCB_REPORT table.
However, It shows below the error ,. Please help.
Invalid object name 'NEW_DCB_REPORT'. -
hi,
pls I have this issue that needs to be resolved. I need to select top five rows from a table depending on the values of a column stock_value. pls I will appreciate if someone can help me out, Francois pls try and help
This is the senerio:
I have a table stock, on the table I have company_name, stock_value, sector.
Now I want to get top five rows from this table depending on the five highest value of stock_value and for each sector.
lets try and write a query that will retrive the records after that I will put it in a procedure.
I know am suppose to ask this on mssql forum but most mssql forums takes time to reply and this is very urgent cos I have to deliver in 45 minutes time
thank you very much
jideoforhy,
try out:
select s.name, sp. sp_sales total_sales
from salesperson s,
(select salesperson_id,sum(tot_sales) sp_sales
RANK() OVER (ORDER BY SUM(tot_SALES) desc) SALES_RANK
FROM ORDERS
WHERE YEAR = 2006
group by salesperson_id) sp
where sp.sales_rank <= 5 (...n)
and sp.salesperson_id = s.salesperson_id
order by sq.sales_rank;
give result in:
name total_sales
a 100
b 90
c 80
d 70
e 60
hope help you
regards -
EPMA Batch client command Equivalent to Select Top Member
Hi
I am looking for EPMA batch client command equivalent to performing "Select Top Members" in web against a shared dimension in Application library.
I can find commands for exclude members in the document but could not find any Dimension Property or Command which will help me to automate this.
Thanks in Advance.
RamI don't believe there is a command that will do that yet.
Cheers
John
http://john-goodwin.blogspot.com/ -
Selecting TOP 20 Products per Catagory
Hi
I'm trying to select the TOP 20 Products per Catagory out of my Star Topology Database
if someone would PLEASE be able to help me out.
Here is my Query: -
SELECT Distinct (SELECT TOP 20 DP.[Description]), DP.Mims_Sub_Cat, SUM(FD.Cost) AS 'Cost'
FROM DIM_Product DP, FACT_Dispensary FD, DIM_Time DT, DIM_Client DC
WHERE DP.Product_KEY = FD.Product_Key
AND FD.Time_KEY = DT.Time_KEY
AND FD.Client_Key = DC.Client_KEY
AND DT.[Year] = 2007
AND DT.[Month] IN (2)
AND Client_name LIKE '%Medicare%'
AND DP.Manufacture_Name LIKE '%Cipla%'
--AND DP.[Description] IN (SELECT TOP 20 [Description])
AND DP.Mims_Sub_Cat IN (SELECT Mims_Sub_Cat)
GROUP BY DP.Mims_Sub_Cat, DP.[Description], FD.Cost
ORDER by DP.Mims_Sub_Cat, SUM(FD.Cost) DESC
My other problem is that it keeps on selecting the same products although i have a distinct in my query
The query will select a product with the amount and then select the same product again with a different amount.
Example :-
Product Descripion Catagory Cost
ULTAK TABS 150MG 60 Acid Reducers 384.94
ULTAK TABS 150MG 60 Acid Reducers 85.54
ULTAK TABS 150MG 60 Acid Reducers 56.98What about:
SELECT * FROM
SELECT DP.[Description], DP.Mims_Sub_Cat, SUM(FD.Cost) AS 'Cost',
RANK() OVER(PARTITION BY DP.Mims_Sub_Cat
ORDER BY SUM(FD.Cost)) AS RANKedColumn
FROM DIM_Product DP, FACT_Dispensary FD, DIM_Time DT, DIM_Client DC
WHERE DP.Product_KEY = FD.Product_Key
AND FD.Time_KEY = DT.Time_KEY
AND FD.Client_Key = DC.Client_KEY
AND DT.[Year] = 2007
AND DT.[Month] IN (2)
AND Client_name LIKE '%Medicare%'
AND DP.Manufacture_Name LIKE '%Cipla%'
AND DP.Mims_Sub_Cat IN (SELECT Mims_Sub_Cat)
) SUbquery
WHERE RankedColumn <=20
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de -
Can i have html code for date select options (SEARCH HELP)
Hi frinds,
I have a BSP Page with input as date.
Can i have html code for date select options (SEARCH HELP)
MoosaHi
Please find the sample code below.
FROM DATE
<htmlb:inputField id = "dd"
width = "45%"
type = "DATE"
showHelp = "X" <- Search help
alignment = "CENTER"
maxlength = "10"
disabled = "TRUE"
value = "<%= w_FROMDATE %>" />
TO DATE
<htmlb:inputField id = "dd"
width = "45%"
type = "DATE"
showHelp = "X"
alignment = "CENTER"
maxlength = "10"
disabled = "TRUE"
value = "<%= w_TODATE %>" />
Thanks
kalyan -
How to select top one in CDS view ?
I have tried following logic to select top one in CDS view but its giving error -
define view Cds_View_First_Reference as select top one CReferredObject from CDSVIEWCROSSREFHi Ruchi,
since you posted this question in "ABAP in Eclipse" I assume you are asking about CDS in ABAP. This is important because the CDS features sets in ABAP and (native) HANA are different.
Be that as it may,, SELECT TOP 1 is neither supported in the CDS implementation in ABAP nor in HANA.
In ABAP you might consider using the min() or max() function together with the appropriate GROUP BY clause in the CDS view (depending on what you want to achieve), but you can also easily "implement" this in the Open SQL statement which selects from your CDS view.
Using the additions SELECT SINGLE or UP TO 1 ROWS and an appropriate ORDER BY clause in Open SQL, you can achieve the same as SELECT TOP 1.
Unfortunately there is currently no possibility to define a view which delivers the TOP 1 which you can again use in another view ("view on view").
Kind regards
Chris -
Prepared Statement, executing SELECT TOP in Ms Access
I'm having the following problem. I built an application fetching data without any problem from MS SQL Server, this was using prepared statements. Now i'm having this strange problem with the following query:
SELECT TOP 1 *
FROM table
WHERE appliance_id = ?
AND ttimestamp_initpk <= ?
AND ((Type = ?) OR (Type = ?) OR (Type = ?) OR (Type = ?) OR (Type = ?) OR (Type = ?))
ORDER BY ttimestamp_initpk DESC
While on SQL Server this fetches just a record, on MS Access it fetches the whole set of records without worrying about TOP instruction.
That is, it acts like a SELECT * FROM, and this slows down runtime behaviour.
I'm using sun.jdbc.odbc.JdbcOdbcDriver, is it the problem?
Thanks, MirkoThanks for your answer, but i'm not sure this is the reason.
I made one more test: i wrote a .Net application connecting to a MS Access using an ODBC connection. SELECT TOP statement is working fine, so i think i'll try another JDBC driver. Any other solution??
Thanks,
Mirko -
Hi,
Can somebody give me the HANA equivalent of the following SQL query:
SELECT TOP (731-624+1) COLUMNNAME FROM TABLENAME
In case of HANA, it gives syntax error near "(".Hi Yash,
As per the HANA SQL syntax supported case is
<select_clause> ::= SELECT [TOP <unsigned_integer>] [ ALL | DISTINCT ]
<select_list>
After Top only an unsigned intger is expected and cannot handle an <expression> like in your example.
Hope this is useful.
Best Regards,
Ranjit -
Date selection and search help component in jsp
Hi all:
In sap portal jsp development enviorment, is it possible to easily program the date selection and search help ( just look like search help in webdynpro ) ?Hello Jianhong,
the easiest way to set a value help is using HTMLB component in your JSP.
To do it, use next code:
<hbj:inputField
id="DateInputField"
type="date"
showHelp="TRUE"
... other attributes
/>
Before using HTMLB components in your JSP, don't forget to add this line to your page:
<%@ taglib uri= "tagLib" prefix="hbj" %>
regards.
mz -
ALV - refresh data after value is selected from input help
Hello,
I have input ALV where after I enter material number and press enter, the logic goes ahead and populates description column by utilizing ON_DATA_CHECK event.
Is is possible to trigger some kind of event after the value is selected from search help without hitting enter key?
When the user done with using search help and clicks on material number that he needs, the value is populated in ALV cell, and this is where I need some event trigger to fire the logic to get description without pressing enter.
Thanks,
AlexAlex, in that case, the alternative you have is to:
- Create a Z structure where you have all the table fields
- Bind the Standard DDIC search help to the Material ID (Importing) and the Description (Exporting)
- Create the whole context node in WD referencing that DDIC structure.
The important thing here is that the context node as a whole must reference the structure in order for this to work, not just the fields affected. This may not be possible or desirable in certain cases.
If you do this, the Description will be populated by the SH through its returning parameter, so you wont have to do anything in WD to retrieve it as for the manual input + Enter cases.
Here you have some help on SHs parameters:
http://help.sap.com/saphelp_nw70/helpdata/EN/35/bdb6e2c48411d1950800a0c929b3c3/frameset.htm
Hope this helps.
Edited by: Alejandro Bindi on Sep 19, 2008 12:36 PM -
At selection-screen value- help
Hi All,
I have a requirement that based on a radio button one at selection-screen value-help is triggered and on based on a different radio button another at selection-screen value-help should be triggered.
can it be achieved.
Regards,
JeetuAT SELECTION-SCREEN - selscreen_event
Syntax
| { ON {para|selcrit} }
| { ON END OF selcrit }
| { ON BLOCK block }
| { ON RADIOBUTTON GROUP radi }
| { }
| { ON {HELP-REQUEST|VALUE-REQUEST}
| FOR {para|selcrit-low|selcrit-high} }
| { ON EXIT-COMMAND }.
Alternatives:
1. ... OUTPUT
2. ... ON {para|selcrit}
3. ... ON END OF selcrit
4. ... ON BLOCK block
5. ... ON RADIOBUTTON GROUP radi
6. ... { }
7. ... ON {HELP-REQUEST|VALUE-REQUEST} FOR
{para|selcrit-low|selcrit-high} }
8. ... ON EXIT-COMMAND
Effect
These additions allow individual evaluation of specific elements of the selection screens of the program. The information as to which selection has triggered the event is contained in the system field sy-dynnr.
Alternative 1
... OUTPUT
Effect
This event is triggered at the screen event PBO of a selection screen. In the event block, the selection screen can be prepared through assignments to the data objects of parameters and selection criteria and through dynamic screen modifications.
Note
The assignments to input fields in the event block AT SELECTION-SCREEN OUTPUT always affect the selection screen and overwrite the user inputs from previous displays of the same selection screen. Assignments in the event blocks LOAD-OF-PROGRAM oder INITIALIZATION, on the other hand, only have an effect at first program start.
Alternative 2
... ON {para|selcrit}
Effect
This event is triggered at the screen event PAI of a selection screen if the content of the input field of a parameter para or a line of a selection criterion selcrit was passed to the ABAP program. In the event block, the user input can be checked. Sending a warning or an error message in the event block makes the fields para and selcrit ready for input again.
No parameter that is defined as a radio button can be specified. For this purpose, the addition ON RADIOBUTTON GROUP is provided.
Note
If a user action takes place in the dialog box for the multiple selection of a selection criterion selcrit, the entries of the selection table are passed to the program, line by line. For each line, the event AT SELECTION-SCREEN ON selcrit is triggered.
Alternative 3
... ON END OF selcrit
Effect
This event is triggered after the selection table selcrit has been fully passed to the program after a user action in the dialog box for the multiple selection has taken place. In the event block, the entire selection table can be checked.
Alternative 4
... ON BLOCK block
Effect
This event is triggered at the screen event PAI of a selection screen if all the input fields of a block block of the selection screen were passed to the ABAP program. In the event block, the user inputs can be checked. Sending a warning or an error message in the event block makes all the fields of the block block ready for input again.
Alternative 5
... ON RADIOBUTTON GROUP radi
Effect
This event is triggered at the screen event PAI of a selection screen if all the fields of a radio button group radi of the selection screen were passed to the ABAP program. In the event block, the user input can be checked. Sending a warning or error message in the event block makes all the radion buttons of the block radi ready for input again.
Note
The individual fields of a radio button group are not passed individually and do not trigger the event AT SELECTION-SCREEN ON par.
Alternative 6
Effect
The event AT SELECTION-SCREEN itself is triggered as the last event of selection screen processing if all the input values were passed to the program. In this event block, all the user inputs can be checked. Sending a warning or an error message in the event block makes all the screen fields ready for input once again.
Alternative 7
... ON { HELP-REQUEST | VALUE-REQUEST } FOR
{para|selcrit-low|selcrit-high} }
Effect
The two events ON HELP-REQUEST and ON VALUE-REQUEST are triggered at the screen events POH and POV of a selection screen if - for the input field of a parameter para or one of the input fields of a selection criterion selcrit - the field help F1 or the input help F4 was called. Other selection events are not triggered.
In the event blocks, a self-defined field or input field can be programmed, which overrides any helps possibly defined in the ABAP Dictionary.
Notes
These event blocks can only be implemented for fields of the selection screen that are defined in the same ABAP program and not in a possibly linked logical database.
With the events for the field and input help, no data is transported between the selection screen and the ABAP program. As with general screens, suitable function modules must be used for these. The parameters and selection criteria changed for the input help are transported to the selection screen.
Alternative 8
... ON EXIT-COMMAND
Effect
This event is triggered if the user has called one of the functions Back, Exit or Cancel. In the event block, possible clean-up actions can be executed.
Example
In these executable programs, a standard selection screen and a further selection screen are defined. In the event blocks AT SELECTION-SCREEN, the inputs in the selection screens can be specially handled using the name p_carrid and the screen number in sy-dynnr.
REPORT demo_at_selection_screen.
Global data
DATA: sflight_tab TYPE TABLE OF sflight,
sflight_wa LIKE LINE OF sflight_tab.
Selection screens
PARAMETERS p_carrid TYPE spfli-carrid.
SELECTION-SCREEN BEGIN OF SCREEN 500.
SELECT-OPTIONS s_conn FOR sflight_wa-connid.
DATA s_conn_wa LIKE LINE OF s_conn.
SELECTION-SCREEN END OF SCREEN 500.
Handling selection screen events
AT SELECTION-SCREEN ON p_carrid.
IF p_carrid IS INITIAL.
MESSAGE 'Please enter a value' TYPE 'E'.
ENDIF.
AUTHORITY-CHECK OBJECT 'S_CARRID'
ID 'CARRID' FIELD p_carrid
ID 'ACTVT' FIELD '03'.
IF sy-subrc = 4.
MESSAGE 'No authorization for carrier' TYPE 'E'.
ELSEIF sy-subrc <> 0.
MESSAGE 'Error in authority check' TYPE 'A'.
ELSE.
IF sy-ucomm = 'ONLI'.
CALL SELECTION-SCREEN '0500'.
ENDIF.
ENDIF.
AT SELECTION-SCREEN.
IF sy-dynnr = '0500'.
IF s_conn IS INITIAL.
MESSAGE 'Please enter values' TYPE 'W'.
ELSE.
SELECT *
FROM sflight
INTO TABLE sflight_tab
WHERE carrid = p_carrid AND
connid IN s_conn.
IF sy-subrc <> 0.
MESSAGE 'No flights found' TYPE 'E'.
ENDIF.
ENDIF.
ENDIF.
Main program
START-OF-SELECTION.
Maybe you are looking for
-
How can I disable the Spam filter on Apple Mail?
Hi All! About a year ago I installed Virus Barrier X6 with Personal Antispam on my 27 inch iMac. The Virus software seems great and I have no issues. The Antispam I have never installed and i have continued with the Junk options, however I have an is
-
My iPod Touch is not working with Bose SoundDock. How can I fix it?
My iPod Touch is not working with Bose DoundDock Series II. Can anyone suggest how I can get these 2 to work together?
-
Ichat AV is giving me error-8 every time i try to video chat
Im using ichat 3.1.8 with a netgear w6r614 router and a motorola sb120 cable modem. I can text chat but the video chat doesn't seem to work. I am set up through the airport on my macbook running os x 10.4.10. my port is 443, what else do i need to do
-
All of a sudden my FCP app will not launch. It was working fine, then I shut down to work in Logic for a while. When I tried to relaunch it crashed and continues to crash repeatedly just as it's booting up. Just before quitting FCP, I created a new c
-
Hi all, i have to build a replication architecture for one of my databases, due to a disaster recovery implementation . Database A must be fully replicated/syncronized to Database B. Database B is in another physical location , and i have an connetio