Questions tagged [top-n]

322 questions
0
votes
1 answer

Getting sum of top n variables in a data frame

totdal_deaths_confirmed_cases_60_days_only = swine_flu_cases %>% filter(Confirmed >0) %>% group_by(Country) %>% summarise(top_n((total_confirmed_cases = sum(Confirmed), total_deaths = sum(Deaths),60)) So I have a dataframe called…
DRC_mami
  • 3
  • 3
0
votes
0 answers

Power BI Top N Bottom Too Many Results

New to Power BI, obvs. I've got too many results showing up in my Top N bottom 10 and would like to eliminate the items that are only single units to clean up the chart. So it looks neat like the Top N top donut. I haven't found any other questions…
Elaine Powell
  • 23
  • 1
  • 10
0
votes
2 answers

Using pyspark RDD .groupByKey extract highest value element per group

TOKEN_RE = re.compile(r"\b[\w']+\b") def pos_tag_counter(line): toks = nltk.regexp_tokenize(line.lower(), TOKEN_RE) postoks = nltk.tag.pos_tag(toks) return postoks pos_tag_counts = text.filter(lambda line: len(line) > 0) \ …
Viktor Avdulov
  • 127
  • 2
  • 14
0
votes
3 answers

I am trying to fetch record from empMaster table for the nth highest Salary.But getting error near 'N'

I am trying to fetch record from empMaster table for the nth highest Salary.But getting error near 'N' . SELECT TOP 1 salary FROM (SELECT DISTINCT TOP n salary FROM empMaster ORDER BY salary DESC) AS temp ORDER BY salary Error…
PoojaP
  • 1
0
votes
2 answers

finding the row with earliest date for each customerID who purchased specific product and return the date in new column

I'm working with PowerBI and have the following table: customer_id|item_id| date 1 | A | 01/01/01 1 | B | 01/01/01 1 | A | 02/02/02 1 | A | 03/03/03 2 |…
Anne D.
  • 3
  • 1
  • 2
0
votes
1 answer

dc.js - How to use cap and othersGrouper in capMixin?

I am trying to create a row chart with dc.js which shows the top 5 URLs and group the rest (not top 5) into 'Others'. From what I have searched online, it is possible by using cap() and othersGrouper() under capMixin…
0
votes
3 answers

I have problem in getting the min of column name TRANS the required output should be TOWN_HALL and 2

SELECT BRANCH_ADD, COUNT(TRANS_AMOUNT) AS TRANS FROM (SELECT A.BRANCH_ADD, C.TRANS_AMOUNT FROM BRANCHES A, ACCTS B, TRANSACTION C WHERE a.branch_code = b.branch_code AND b.acct_no =…
0
votes
3 answers

Return the article with the latest date, sql max(DATE)

I have the following query: SELECT MAX(b.upd_dtime) as MaxT, b.vo_no as vo_no, y.item_no FROM vo_order_t b JOIN ( SELECT a.vo_no, a.item_no FROM vo_item_t a where a.item_no IN('00265929')) y ON y.vo_no = b.vo_no GROUP BY b.vo_no,…
Bryan
  • 3,421
  • 8
  • 37
  • 77
0
votes
2 answers

oracle query for get 20 top agency which have pass issued

I have a query which show datewise pass issued by agency. I wanted to get top 20 agency who have most pass issued here is my query
mdkamrul
  • 274
  • 1
  • 13
0
votes
1 answer

top_n for 2 conditions

I have a question regarding top_n function of dplyr. How can I use the top_n function two extract values based on two columns. Following example: I have a data frame DT. Now I want to extract the top 5 rows. But I want to first order it based on Y.…
Hu_Ca
  • 47
  • 1
  • 5
0
votes
1 answer

head() or top_n() function changing format of the numeric values in the dataset

The R head() and top_n functions are removing decimals from two of my numeric columns and I cannot figure out why? I am using R 3.4.4 with RStudio 1.2.5 and dplyr . I have got a dataset with 4 numeric columns along with four other types of…
0
votes
2 answers

How to get the 10th highest cost in ORACLE?

I have a table products and i have column standard_cost and I want to get the standard cost of the product which lies in 10th highest position. So far I tried SELECT t1.* FROM (SELECT STANDARD_COST FROM OT.PRODUCTS ORDER BY…
Ashwin Karki
  • 249
  • 4
  • 18
0
votes
1 answer

Is there an R function to use with top_n when scores are equal

I'm doing correlations on school leaving scores and University scores. I use top_n to clean the school scores of retakes, but sometimes the poor candidate gets the same score on retake. How to eliminate these duplicates ? Studno Math
CharlotteM
  • 47
  • 4
0
votes
1 answer

how can I update a top 1 records in teradata

I am trying to update the first record clubcode + campaigncode + region based on their tenureyear. (Tenureyears is causing the duplicate records but I need them) This works in T-SQL but not Teradata update MYTable set qtyupdate =(SELECT quantity …
user3720099
  • 33
  • 1
  • 5
0
votes
1 answer

Last 3 Employment information for each person in a ROW

I need to display the last three employer names for each person in a row. I have used the Rank() and Max() approach and was wondering if there is an easy way to solve this using analytics functions. I tried using NTH_VALUE but I still needed the max…
avg998877
  • 127
  • 1
  • 4
  • 12