Questions tagged [ranking-functions]

Ranking functions return a ranking value for each row in a partition. Depending on the function that is used, some rows might receive the same value as other rows. Ranking functions are non-deterministic.

193 questions
0
votes
2 answers

How to compute SQL query complexity

I have a table with only 3 columns: id, name and timestamp , and it is required to extract for each id (and therefore for each name) the most recent timestamp. For example having this…
0
votes
2 answers

How to create a ranking variable/function for different periods in a panel data?

I have a dataset, df, that looks like this: Date Code City State Population Quantity QTDPERCAPITA 2020-01 11001 Los Angeles CA 5000000 100000 0.02 2020-02 11001 Los Angeles CA 5000000 125000 0.025 2020-03 11001 Los…
RafaelP
  • 83
  • 7
0
votes
1 answer

SQL - Rank function

I am trying to rank data based off multiple factors and having trouble doing so. I want to rank each Batch and Material based off the most recent entry date and max value material doc item. (So 2 over 1 etc) In the above sample data I would expect…
tomfbsc
  • 45
  • 5
0
votes
2 answers

How to add this Rank Over Partition By in C#?

I am trying to add a Rank Over Partition By as a table column. I am first starting with a simple example. However, I receive the following error message: I first created the rank variable that should hold the rank values. I then added the rank…
user17824052
0
votes
1 answer

postgresql query how to append dups counter to name column

I have table here. how to find all duplicate records, considering length(name)=3 ? and append dups counter to the name as a suffix? Below screenshot, Key 6 and 7 has characters length > 3 and when length(name)=3 then Jay is there two times so Key 6…
Hari
  • 299
  • 4
  • 12
0
votes
3 answers

Pandas Ranking for String Columns

I have a sample dataframe like this. Basically I want to do ranking based on item_number and location_id. I could've done something like that in SQL using window function (dense_rank, over() partition by). df = pd.DataFrame({'item_number': [1029980,…
hkay
  • 159
  • 1
  • 2
  • 12
0
votes
1 answer

how to perform Rank query in Django

I am stuck at this point and this query seems a bit tricky to me so basically i am getting data from devices in periodic intervals 'lets say 3 hours' But every device is sending data twice on every interval(3 hours), i am required to extract device…
Atif Shafi
  • 954
  • 1
  • 11
  • 26
0
votes
1 answer

How Do you Rank a Dictionary of Numbers From Local Storage in Javascript?

for(var i=0, len=localStorage.length; i " + value); let users = value.username; let scores =…
0
votes
1 answer

Using RANK() to assign a rank based on multiple criteria in Oracle

I have a table similar to: Item Class Qty Loc Apple Fruit1 1 N Apple Fruit1 1 NW Apple Fruit2 0 W Apple Fruit3 1 N Orange Fruit1 10 SE Orange Fruit2 1 SW I am trying to query all rows with the lowest Class that has the smallest…
Luxo_Jr
  • 379
  • 1
  • 3
  • 12
0
votes
1 answer

Consecutive n week calculation

I have a table consisting of 3 columns: Product, Week, Units Sold. I am trying to come up with a table to show the best consecutive 4 week sales. I have tried several different window analytical functions and can’t seem to get what I need. This is…
J..
  • 3
  • 1
0
votes
1 answer

Rank on multiple columns in Oracle 19C

Could you please suggest a simple way to calculate rank on multiple columns in Oracle 19c. For instance - considering [ Mango | 1 | 1 ] group from the table NAME DAY PROD S M P AMT1 AMT2 …
0
votes
0 answers

sub ranking rows with google sheet array-formulas

i have a chart of accounts with multiple sub levels and i'm trying to get a dynamic serial number for table rows that depends on ranking and previous column , I've already used sheets formulas and i want to convert all formulas into array formulas…
0
votes
3 answers

Ranking functions and Joins

I have the following…
Striker
  • 3
  • 1
0
votes
1 answer

Advice on how to rank based on a score

Im new to trying to use algorithms and interested if there is some advice on what topics I could research to try and solve my problem. Below is a chart that I'm trying to understand how I could rank all of the competitors and occurrences (you'll…
Rob Porter
  • 71
  • 2
  • 10
0
votes
1 answer

get rank of individual rows with data from another table

Rank using a left join of another table data. The app has tokens where the users can vote on. I want to be able to display the rank of each token in the app... The final objective is to create a MySQL view the query, but when trying to create the…