Questions tagged [top-n]

322 questions
0
votes
1 answer

Sparklyr Spark 2.1 generate top n recommendation

R version 3.3.0 (2016-05-03) Sparklyr version ‘0.7.0’ Spark version 2.1 on YARN client I am using Spark framework in R using Sparklyr for generating top-5 recommendations for products which are likely to be sold and their expected quantity using ALS…
0
votes
1 answer

Count words in string, grouped by year

I'm trying to find popular words in a string using R, which is probably easiest to explain with an example. Taking this as the input (with millions of entries, where each date can appear thousands of times) IncorporationDate …
Ian
  • 3
  • 3
0
votes
1 answer

How to find Top n topics for a document

I am using the tf - IDF to rank terms in a document. When terms are arranged in descending order of the tf - IDF, top 'n' terms are most relevant to that document. When we choose a document, top 'n' terms of that document has to be displayed. My…
0
votes
4 answers

How to Get Set of Second Highest Values?

Suppose I have the following table: employee_id salary 34 100 22 49 19 49 29 30 17 22 And I want to return the set of employees with the second highest salaries…
ajf1000
  • 409
  • 5
  • 13
0
votes
0 answers

MySql Select Top N records on Each Group

I am using MySql DB. My table looks as below: And I would like to get the output as follows: I tried to use Over Partition and other method, however I couldn't get what I want. Can someone kindly help?
Senthil
  • 43
  • 6
0
votes
2 answers

Group oracle table by name and order by time desc with time should be maximum for today's timestamp

Suppose I have a table as below in Oracle database ID NAME SAVED_ON _____________________________ 10 APPLE 10-DEC-17 03.08.26.353000000 PM 15 MANGO 10-DEC-17 05.08.26.353000000 PM 17 APPLE 10-DEC-17…
0
votes
1 answer

create a new calculated table having top funded categories each year

A table contains 3 columns namely Year, Category and Amount in which the year and amount is a calculated column. Table 1: +------+----------+--------+ | Year | Category | amount | +------+----------+--------+ | 2016 | A | 50 | |…
0
votes
1 answer

Oracle rownum = 1 to select topmost row from the set fails

I need to select from two tables, RATING_TABLE RATING_TYPE RATING_PRIORITY TITAN 1 PLATINUM(+) 1 PLATINUM 2 DIAMOND(+) 3 DIAMOND 3 GOLD 4 SILVER …
0
votes
2 answers

Select TOP N and BOTTOM N

Trying to fetch top n bottom n rows. Though it gives me result but, it takes lot of time. I believe it scans table twice. Code used: WITH TI AS (SELECT * FROM (SELECT Column1, Column2, Colmn3 FROM TABLE ORDER BY DESC ) WHERE ROWNUM<=5), T2…
Novice_Techie
  • 426
  • 3
  • 10
  • 21
0
votes
1 answer

Neo4j, How to return the top n from diffreent tag groups?

I have a database which represents "Posts", it contains creation date, tags, titles. some posts are answers to other posts, then some posts are questions and other posts are answers. The task here is to find the questions which have the shortest…
kyandy
  • 21
  • 6
0
votes
2 answers

SQL query challenge - find top frequent items in columns and summarize result to a pivot table

I am looking for a query to do following transformation. Basically I want to find top 3 frequent SELL_COUNTRY and top 3 frequent category, on per website, per day bases. (for example, website 1, date 6-5-2017, there are 2*US, 1*JP and 1*UK for…
user1269298
  • 717
  • 2
  • 8
  • 26
0
votes
3 answers

random join in SQL Server with a varying number of random results

SQL Server's SQL has become so clever that what looks like it might require a procedural solution can often be done with pure SQL. I am wondering if this is one of those times. Let's say we have a STATES table and a CITIES table. STATES: State: …
Tim
  • 8,669
  • 31
  • 105
  • 183
0
votes
3 answers

How to get minimum number of records for a condition in oracle

I want to get a minimum number of record based on my condition I give in where condition. for ex: I have a table with two columns(Id, Value) My table has data like following: Id Value 1 001 2 001 3 001 4 002 5 002 6 003 …
Santosh
  • 2,355
  • 10
  • 41
  • 64
0
votes
1 answer

I want a T-SQL procedure or sql query to perform the following action:

I have a table with these rows: City | Day NEWYORK | MON NEWYORK | MON NEWYORK | MON NEWYORK | TUE CHICAGO | MON CHICAGO | MON I need to write a query to add column Occurrence to the result using data from Columns City and Day: City |…
0
votes
1 answer

MySQL - Calculate percent of total by group

State ID Value Result1 (%) Result2 (Rank) MA AAA 44 0.24 2 MA BBB 12 0.07 4 MA CCC 90 0.50 1 MA DDD 34 0.19 3 CT …