Top 10 values in each category
I have a table that has the following columns:
Category Item Cost
I would like to find out what the top 10 most expensive items are in each category. Is there a way you can do this with 1 SQL statement??? I have tried using the rank analytical function, but to no avail. Any help would be appreciated. Thanks!!!
select *
from ( select category, item, cost, row_number()
over ( partition by category order by cost desc) top10
from t01)
where top10 <= 10
Best Regards
Krystian Zieja / mob
Similar Messages
-
HT204266 How can I find the top 300 games in each category on iPad App Store?
From iPhone Apps Store I could go to each category and find the top 300 games, how could I find the top iPad games in each category in iPad Apps Store? Thanks!
i downloaded it already but it should have the iTunes U App in my homepage as a shortcut. now, it doesn't have this icon in my apps pages. when i need to use it, i have to open the App store and search it out every time. For example, after downloaded the Facebook App, it would have a FB App in my homepage. my Question is I DON'T HAVE THE ITUNES U App IN MY HOMEPAGE NOW. T___T do you have any method to get it in my homepage.
anyway thank you for your link. -
I have my SSRS report to show the top 3 volumes by physician. My problem is it shows them in three lines going down, even though the code is in one cell. Such as:
Dr Smith
Dr Johnson
Dr James
I need it to show as Dr Smith, Dr Johnson, Dr James (all on one line separated by commas). Here is what I have tried:
=Switch(RunningValue(Fields!Attending_Pract_Name.Value,CountDistinct,Nothing)=1,
Fields!Attending_Pract_Name.Value) & ", " &
Switch(RunningValue(Fields!Attending_Pract_Name.Value,CountDistinct,Nothing)=2,
Fields!Attending_Pract_Name.Value) & ", " &
Switch(RunningValue(Fields!Attending_Pract_Name.Value,CountDistinct,Nothing)=3,
Fields!Attending_Pract_Name.Value)
But it still puts the list going down instead of side by side. Any ideas?Hi cpemtp1,
Based on my understanding, there is a column with a lot of rows. Now, you want to combine data of top three rows into one line, right?
In Reporting Services, when generating each detail row, it only pass one value of data field into expression. So we can never simply using expression to combine three values within one data field together. Regarding your expression, for each row, if this
value meets requirement, the expression returns this value, otherwise it returns null value. In your scenario, if you only want to display those top three values in your tablix, I would recommend you create another dataset and combine data of top three rows
to one line on query level. Please refer to screenshots below:
Reference:
Use PATH Mode with FOR XML
How to combine values from multiple rows of a single column (T-SQL, Microsoft SQL Server, FOR XML PATH, CSV ).
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu -
Please Help regard function that will return values of each JComboBox items
I'd like to create a function that will return values of each item on the JComboBox at a time when
I click on each item of a comboBox. I had this following codes, but didn't work.
Please help me !!!Please correct it... thanks a million
String wp;
String text;
String A[] = {"WARNIGNS","CAUTIONS","NOTES"};
JComboBox ABC = new JComboBox();
for (int i=0;i<A.length;i++) {
ABC.addItem (A);
text = Get_It(); //assigns each value of JComboBox's item to variable text when clicks at each item
//of a comboBOx
private String Get_It(){
ABC.addActionListener(new ActionListener (){
public void actionPerformed(ActionEvent e){
wp = (String)CBweapon.getSelectedItem() ;
return wp;import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class AlertFrame extends JFrame {
String s_alert[] ={"WARNIGNS","CAUTIONS","NOTES"};
JComboBox CBweapon;
String wpText;
public AlertFrame() {
super("Alerts");
Container contentPane = getContentPane();
contentPane.setLayout(null);
setSize(600,600);
CBweapon = new JComboBox();
for (int i=0;i<s_weapon.length;i++) {
CBweapon.addItem (s_weapon);
contentPane.add(CBweapon);
CBweapon.setActionCommand("");
//set position for components
CBweapon.setBounds(370 + insets.left,295+ insets.top, 150,30);
System.out.println(getit()); //calling getit() function
//this function will be return a String of JcomboBOx value if click on each item of combobox
private String getit(){
CBweapon.addActionListener( new ActionListener (){
public void actionPerformed(ActionEvent e){
wpText = (String)CBweapon.getSelectedItem() ;
return wpText;
public static void main(String args[]) {
AlertFrame af = new AlertFrame();
af.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
**I have no errors on compile or run, but it didn't return a string value to System.out.println(getit());
It maybe because of the "void" of public void actionPerformed(ActionEvent e){
wpText = (String)CBweapon.getSelectedItem() ;
Please help me -
How to restrict aggregation to top-N values per grouping?
Hi all,
Using Oracle's EMP table as an example, the following query sums the total of all salaries for each department. How can the query be altered (hopefully, in a simple manner) so that it will only sum the top N salary values for each department?
select deptno, sum(sal)
from emp
group by deptno
order by deptno
Hopefully, the query doesn't need to be rewritten or altered significantly. I'm hoping there is a simple and straight-forward approach.
Thank you so much,
Kim... sum the top N salary values for each department?
The ethernal doubt: does 3 denote positions or values
with
t as
(select deptno,sal,
dense_rank() over(partition by deptno order by sal desc) rnk
from emp
select deptno,
sum(sal) top3_sum
from t
where rnk <= 3
group by deptno
order by deptno
DEPTNO
TOP3_SUM
10
8750
20
10075
30
5950
Regards
Etbin
Message was edited by: Etbin Oops! should have looked before posting as I got distracted. My bad. -
How to get top 11 values per date range
I want to get the top 11 values by date range.
Sample Data
CREATE TABLE SAMPLE_DATA
DOMAIN_NAME VARCHAR2(100),
QTD NUMBER,
LOAD_DATE DATE
-- Insert
BEGIN
FOR lc IN 1..20
LOOP
FOR ld IN 1..30
LOOP
INSERT
INTO SAMPLE_DATA VALUES
'DM_'
||lc,
round(dbms_random.value(0,1000)),
SYSDATE-ld
END LOOP;
END LOOP;
COMMIT;
END;
SELECT *
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM SAMPLE_DATA
WHERE LOAD_DATE = TRUNC(SYSDATE-3)
ORDER BY QTD DESC
WHERE ROWNUM <=10
UNION ALL
SELECT 'Others' DOMAIN_NAME,
SUM(QTD) QTD,
LOAD_DATE
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT rownum rn,
DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM SAMPLE_DATA
WHERE LOAD_DATE = TRUNC(SYSDATE-3)
ORDER BY QTD DESC
WHERE rn > 10
GROUP BY LOAD_DATE
ORDER BY QTD DESC
-- Result
DOMAIN_NAME QTD LOAD_DATE
Others 2888 24/03/13
DM_1 1000 24/03/13
DM_20 933 24/03/13
DM_11 913 24/03/13
DM_3 743 24/03/13
DM_13 572 24/03/13
DM_12 568 24/03/13
DM_9 564 24/03/13
DM_6 505 24/03/13
DM_5 504 24/03/13
DM_2 480 24/03/13
Please, Help me get in one query this result using a range of date.
e.g
using LOAD_DATE BETWEEN '24/03/13' AND '25/03/13'
DOMAIN_NAME QTD LOAD_DATE
Others 2888 24/03/13
DM_1 1000 24/03/13
DM_20 933 24/03/13
DM_11 913 24/03/13
DM_3 743 24/03/13
DM_13 572 24/03/13
DM_12 568 24/03/13
DM_9 564 24/03/13
DM_6 505 24/03/13
DM_5 504 24/03/13
DM_2 480 24/03/13
Others 1948 25/03/13
DM_1 807 25/03/13
DM_8 764 25/03/13
DM_7 761 25/03/13
DM_11 656 25/03/13
DM_18 611 25/03/13
DM_17 523 25/03/13
DM_14 467 25/03/13
DM_19 447 25/03/13
DM_15 437 25/03/13
DM_6 380 25/03/13 Thank you in advance.I got the solution. Just sharing.
I used analytic functions that make my job easy.
Sample Data
DOMAIN_NAME QTD LOAD_DATE
DM_1 807 25/03/2013
DM_1 1000 24/03/2013
DM_2 226 25/03/2013
DM_2 480 24/03/2013
DM_3 244 25/03/2013
DM_3 743 24/03/2013
DM_4 48 25/03/2013
DM_4 413 24/03/2013
DM_5 164 25/03/2013
DM_5 504 24/03/2013
DM_6 380 25/03/2013
DM_6 505 24/03/2013
DM_7 761 25/03/2013
DM_7 212 24/03/2013
DM_8 764 25/03/2013
DM_8 308 24/03/2013
DM_9 354 25/03/2013
DM_9 564 24/03/2013
DM_10 214 25/03/2013
DM_10 367 24/03/2013
DM_11 656 25/03/2013
DM_11 913 24/03/2013
DM_12 37 25/03/2013
DM_12 568 24/03/2013
DM_13 332 25/03/2013
DM_13 572 24/03/2013
DM_14 467 25/03/2013
DM_14 87 24/03/2013
DM_15 437 25/03/2013
DM_15 450 24/03/2013
DM_16 238 25/03/2013
DM_16 299 24/03/2013
DM_17 523 25/03/2013
DM_17 143 24/03/2013
DM_18 611 25/03/2013
DM_18 145 24/03/2013
DM_19 447 25/03/2013
DM_19 464 24/03/2013
DM_20 91 25/03/2013
DM_20 933 24/03/2013 Top 11 QTD of DOMAIN_NAME per Data Range.
SELECT *
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT LOAD_DATE,
DOMAIN_NAME ,
QTD,
(DENSE_RANK() OVER (PARTITION BY LOAD_DATE ORDER BY QTD DESC )) AS RANK_QTD
FROM SAMPLE_DATA
WHERE trunc(load_date) BETWEEN '24/03/2013' AND '25/03/2013'
WHERE RANK_QTD <= 10
UNION ALL
SELECT 'Others',
SUM(QTD) AS QTD,
LOAD_DATE
FROM
(SELECT LOAD_DATE,
DOMAIN_NAME ,
QTD,
(DENSE_RANK() OVER (PARTITION BY LOAD_DATE ORDER BY QTD DESC )) AS RANK_QTD
FROM SAMPLE_DATA
WHERE trunc(load_date) BETWEEN '24/03/2013' AND '25/03/2013'
WHERE RANK_QTD > 10
GROUP BY LOAD_DATE
ORDER BY LOAD_DATE ASC,
QTD DESC
DOMAIN_NAME QTD LOAD_DATE
Others 2888 24/03/2013
DM_1 1000 24/03/2013
DM_20 933 24/03/2013
DM_11 913 24/03/2013
DM_3 743 24/03/2013
DM_13 572 24/03/2013
DM_12 568 24/03/2013
DM_9 564 24/03/2013
DM_6 505 24/03/2013
DM_5 504 24/03/2013
DM_2 480 24/03/2013
Others 1948 25/03/2013
DM_1 807 25/03/2013
DM_8 764 25/03/2013
DM_7 761 25/03/2013
DM_11 656 25/03/2013
DM_18 611 25/03/2013
DM_17 523 25/03/2013
DM_14 467 25/03/2013
DM_19 447 25/03/2013
DM_15 437 25/03/2013
DM_6 380 25/03/2013 -
Can you calculate multiple text boxes to achieve a total value? If so how is that done? I am trying to create a order form where multiple items can be purchased but i would like the values of each item to calculate so I can achieve a total value.
Hi sashby51,
I've moved your discussion to the PDF Forms forum--the folks who visit this forum regularly should be able to point you in the right direction.
Best,
Sara -
How to retrive KFF segment values in each row of VO?
Hi,
I need to retrve Special Information Type values in HR screen.
There is a table based on the VO and on of the column is a flex (KFF) linked ot the same VO.
How can i retrieve the KFF segments values from each row of the table (or VO row).
The VO contains the ID_FLEX_NUM only.
Specific issue details:
It is an HR screen
page : PersonSIT Page
Region : SpecialInformationType(Table)
VO : SpecialInformationDetailsVO
flex id="HrSitKeyFlex" flexName="PEA" flexFieldAppShortName="PER" user:akAttributeCode="HR_PERSON_SIT_FLEX"
Any information is of great help
Thanks,
Kamath..Vo Query is
SELECT /*+ ORDERED */pac.analysis_criteria_id,
ppa.analysis_criteria_id old_analysis_criteria_id,
ppa.person_analysis_id,
ppa.object_version_number,
ppa.id_flex_num,
ppa.business_group_id,
ppa.person_id,
ppa.date_from,
ppa.date_to,
'DB_ROW' status,
ppa.date_from old_date_from,
ppa.date_to old_date_to,
ppa.attribute1,
ppa.attribute2,
ppa.attribute3,
ppa.attribute4,
ppa.attribute5,
ppa.attribute6,
ppa.attribute7,
ppa.attribute8,
ppa.attribute9,
ppa.attribute10,
ppa.attribute11,
ppa.attribute12,
ppa.attribute13,
ppa.attribute14,
ppa.attribute15,
ppa.attribute16,
ppa.attribute17,
ppa.attribute18,
ppa.attribute19,
ppa.attribute20,
ppa.attribute_category
FROM per_person_analyses ppa,
per_analysis_criteria pac
WHERE ppa.business_group_id = :1
AND ppa.person_id = :2
AND ppa.id_flex_num = :3
AND pac.analysis_criteria_id = ppa.analysis_criteria_id
The values from log file for a single row is as below
i = 0
row.getAnalysisCriteriaId()=68198
row.getAttribute1()=null
row.getAttribute10()=null
row.getAttribute11()=null
row.getAttribute12()=null
row.getAttribute13()=null
row.getAttribute14()=null
row.getAttribute15()=null
row.getAttribute16()=null
row.getAttribute17()=null
row.getAttribute18()=null
row.getAttribute19()=null
row.getAttribute20()=null
row.getAttribute2()=null
row.getAttribute3()=null
row.getAttribute4()=null
row.getAttribute5()=null
row.getAttribute6()=null
row.getAttribute7()=null
row.getAttribute8()=null
row.getAttribute9()=null
row.getAttributeCategory()=null
row.getBusinessGroupId()=83
row.getDateFrom()=2009-10-01 03:32:38.0
row.getDateTo()=null
row.getIdFlexNum()=50454
row.getPersonAnalysisId()=null
row.getObjectVersionNumber()=null
row.getOldAnalysisCriteriaId()=null
row.getOldDateTo()=null
row.getOldDateTo1()=null
row.getPersonId()=46788
row.getSelectFlag()=Y
row.getStatus()=NEW_ROW
Here, row.getIdFlexNum()=50454 is the id_flex_num- KFF structure code which has 4 segments.
I need to get the value for the VaueSet of Segment1
The segment values are displayed in the OAF page but i did not get how did std oracle code fetch it
Thanks,
kamath -
Can I sum only the top 10 values in a range?
I am new to mac and numbers. I bought my first mac this fall. I have a grade book in Numbers. I am only counting the top 10 out of 11 homework scores and top 10 out of 13 quiz scores.
Essentially, I want to add the top K values out of a range of N cells. Can I do this?
Thanks.you can use the large() function like this:
C1=AVERAGE(LARGE(B,1), LARGE(B,2), LARGE(B,3), LARGE(B,4), LARGE(B,5), LARGE(B,6), LARGE(B,7), LARGE(B,8), LARGE(B,9), LARGE(B,10))
this is shorthand for... select cell C1, then type (or copy and paste from here) the formula:
=AVERAGE(LARGE(B,1), LARGE(B,2), LARGE(B,3), LARGE(B,4), LARGE(B,5), LARGE(B,6), LARGE(B,7), LARGE(B,8), LARGE(B,9), LARGE(B,10)) -
How to display top 10 values in a Webi report?
Hi,
I have the following requirement.
If the report contains 'State' and 'Revenue' columns, I need to display top 10 cities with highest revenue and the revenue of the remaining cities can be summed together and should be available in a separate cell.
I tried several formulae to achieve the requirement but was unsuccessful.
I created a variable using the formula: '= If (Rank(<State> ,<Sales revenue>)>10 ) Then Sum(<Sales revenue>) Else 0' and added it as a column in the report. This provides the required results.
When I add this variable as a column in the report, it displays 0 for the first top 10 values and only displays the remaining values. After that we can apply the Sum on this column to get the sum of the remaining (Other) sales revenue excluding top 10 values. However I cannot display this sum in a separate cell.
Please provide some suggestions on this.
Regards,
Aditya JoshiHi Aditya,
Could you please try the following solutions to resolve the issue.
Solution1:
In Oracle, there is a function called: RANK() OVER (PARTITION BY () ORDER BY ()) which can be used to define an object at Universe level to return a rank position when used in a report. If you can check with your DBA - there is a similar function available for SQL Server. It should be RANK() OVER (ORDER BY colname) AS () FROM.
Solution2:
Or you can also try returning all rows in query, apply sort at report level & apply alerter to highlight the top 10 values.
Regards,
Sarbhjeet Kaur -
More than one Value for a Category
Hello,
it is possible to assign more than one value of a category to a document by assigning the category once more. Is it a bug or a feature?
If it is not a bug, I wonder why it is not possible to search for a document with two values of one category set? And why isn't it possible to combine category values with "OR" in my search query?
Best regards,
ChristianOnly one video role, only one audio roll, per clip. Only one as these are "Media Stems", and when you work with Stems, only one roll per asset video, one per asset audio.
-
How to get the latest credit limit values per each customer in the report.
Hi All,
Can anybody give me an idea on how to get the latest credit limit values per each customer in the report.
I have below requiremnt.
I have cube which is having transactional data on document and customer level .and it also having master data info object in the cube which is credit management view having all the customer numbers .
This credit management view is master data info object having credit limit key figure as attribute.These credit limit are per each customer.
So we need these credit limits in the report as dynamic values .(I mean whatever be the current credit limit in the master data table for that paricular customer that should show up in the reporting).
one more thing these credit limits should roll up correctly at the HTR level.
One HTR having number of customers .
for example HTR 100 can have customer number 200,300,400.
Those 200,300,400 customer credit limits should roolup correctly at the HTR 100 level.
Example below :
Cube DATA :
HTR Customer Doct number Credit managment view
100 200 10001 200
100 200 10002 200
100 300 10004 300
100 300 10005 300
100 400 10006 400
100 400 10007 400
100 400 10008 400
Master data tabel (P Table)(Credit managment view)
Credit managment view Credit limits
200 1000.00
300 50000.00
400 90000.00
Please remeber :
We can not make these credit limits as navigational becasue these are keyfigure attributes not characteristics.
one more thing we can not make them as charatistics because we need use these credit limits to derive other calkculation. so it is not possibel to derive calculations on charactristics .Create a formula variable of type replacement path with reference as attibutes of Credit management view and choose your key figure credit limit,say zcredit.
Now create a formula or CKF and use zcredit.
This should display the credit limit in your report as normal key figure.
I didnot get this part "one more thing these credit limits should roll up correctly at the HTR level.", may be the above will solve this too.Try it.
Hope this helps. -
How to get top 10 records for each option in table prompt?
Hi,
I have created one report in which my requirement is to get top 10 highest salaries for each departments. I have created one table prompt which contains the names of all departments. On the salary column I have applied one filter i.e. TOP 10. Currently I am having 3 departments. I want to show the top 10 salaries for each department, but I am getting top 3 from first, 4 from second and 3 from third.They are calculating top 10 salaries based on all departments, not on individual department. How can I get top 10 salaries for each department?Hi,
Use TopN function in your column formula.
Ex: TOPN("Sales ,5 BY department)
Thanks,
Satya -
Set as default value the Item Category in the Maintenance Order
Hello everyone,
We are trying to find a user exit in order to set as default value the item category in the Maintenance Order once the Material has been introduced (Tag Components).
SAP Customizing let the user set the Item Category automatically per Material Type, but we need to set different Item Categories to materials belonging to the same material type.
We would really appreciate any help relating this issue.
Thank you very much,
Víctor LiedoDear Paul,
Thank you very much for your response.
I had already tried customizing mentioned by Pithan, but it did not work because we need to set different Item Categories for Materials with same Material Type.
We have been searching for exits which may let us set Item Category in the Maintenance Order, but it does not seem to be possible.
What you say about adding some custom validation through user exit, not to set item category as default value, but to check if the one entered is valid, sounds the best way of achieving our commitments.
I have tried to look for CNEX0037 & CNEX0038, by using transactions SE37 and SE38, search for programs and functions modules, but it did not work. Could you please tell us what kind of objects are?
Thank you very much in advance.
Víctor Liedo -
How to set Dropdown list in tablen whith others Dropdown values in each row
how to set Dropdown list in tablen whith others Dropdown values in each row of the table
hi ,
You have to add the parent element before adding data to the child node ...you follow the below steps it will work
1) Take ContextStructure as follows ...
tabledata (valuenode)
ddownbyindex( value node) --within the tabledata node
value (attribute)
2)Binding to your layout
tabledata (node) ---bind this to the dataSource property of your table
ddownbyindex( node)
Value (attribute)--bind to the texts property of you DDbyIndex
3)In wdinit() method add the following code
IPrivate<Your view name>.ITabledataElement tabledataElement =wdContext.createTabledataElement();
wdContext.nodeTabledata().addElement(tabledataElement);
for(int i=0;i<5;i++)
IPrivate<Your viewname>.IDdownbyindexElement ddbyindexElement=wdContext.createDdownbyindexElement();
ddbyindexElement.setValue("Value"+i);
wdContext.nodeDdownbyindex().addElement(ddbyindexElement);
And set the cardinality property of the table node as 0..n
and dropdownbyinex node to 1..n
You try it ...
Regards
Madhavi
Edited by: madhavi kotra on Sep 2, 2008 6:00 PM
Maybe you are looking for
-
Can I delete account without deleting messages?
I have old email messages from friends and family that I want to keep in my mail folders, but I no longer use that email account. Can I delete the account without deleting all the historic email associated with it? Or do I have to look at that now gr
-
Communication between a driver and application.
Communication between a driver and application. I am writing a driver for a PCI card. I have found very good examples of how the driver should be build. Where do I find the information about how the user mode application should be talking the driver.
-
How to I get play count on my iphone to show up in itunes on new mac?
I got a new macbook pro and downloaded the music from my other computer through homeshare. The play count on my phone would show up on the old computer but hasnt on the new mac even after syncing multiple times. I want the play count from the old com
-
Bluethoot: I have device paired n like to delete ::: immediately
How do I remove a device from the list? Hello to all!! First time on this... I also need your expertee. I have a Bluethoot paired on my mac, Bluetooth-PDA-Sync RS-232 that it was never paired by me... It seems to be a modem, but here is the thing..Th
-
Sent mails from CRM are not reaching to destination..
Hi experts, good afternoon. I have configured an action to trigger an email when the document is saved. But the problem is action is shown as executed in transaction level, even in SCOT it is showing as completed but in SOST sent mails it is not sho