Skip to main content
-1 votes
1 answer
56 views

mySQL how to increment by a group ---why doesn't this work?

I have a table in mySQL like the below, and I'm trying to assign an incremented number to the group based upon ID's, but it's not working. My query: select row_number() over (partition by IDs) from ...
John Smith's user avatar
-1 votes
1 answer
82 views

row_number giving me trouble when called from a join [closed]

When I run the code below I get no results, but if I remove the b.row field from the first select statement, I do get the expected result set. What I want ultimately, is to have a column in the result ...
Ponce's user avatar
  • 101
0 votes
1 answer
75 views

Setting a row number for each row in PySpark Dataframe

Currently I'm working with a large database using PySpark and stuck with a problem oh how to correctly set row numbers depending on condition My dataframe is: id_company id_client id_loan date c1 ...
lenpyspanacb's user avatar
0 votes
0 answers
149 views

ROW_NUMBER() OVER (PARTITION BY [variable] ORDER BY NEWID() - seems to select the same output every time and not random

I have a table with over 1.8 million rows and around 200 columns, which I will call [DBO].[DATA]. The only columns in this table that are really relevant to this query are [TEMP_PERSON_ID], [AGE] and [...
Arsinq's user avatar
  • 25
1 vote
1 answer
86 views

SQLite query to compute row number without row_number etc

I have a table of string values where the natural sort order is first by length and then by value. i.e., CREATE TABLE t(v VARCHAR(255)); INSERT INTO t(v) VALUES ('100'), ('10'), ('8'), ('5'), ('3'), (...
Nik's user avatar
  • 2,409
1 vote
0 answers
50 views

MariaDb, calculating median value for limited number of values from linked table

Having two tables, representing phones and their out-coming calls, I'd like to get list of phone numbers along with median value of last 5 call duration, in case there is at least 5 calls for number ...
MMitrich's user avatar
1 vote
1 answer
60 views

Rank rows by specified partition

This is my fiddle I have a table like this create table CTE1 ( [CC Receiver] VARCHAR(10), Name VARCHAR(255), [Division] varchar(10), [Old Block] varchar(10), [Date] Date, Round ...
Fachry Dzaky's user avatar
0 votes
1 answer
74 views

SQL Query to Rank Customers Based on Diversity of Cuisines Tried

I need help with a SQL query that ranks each customer based on the diversity of cuisines they have tried. The rank should be unique (not repeated) and should not skip any values. The goal is to ...
Sai SP's user avatar
  • 15
-4 votes
1 answer
32 views

row_number could not be used in array_to_string(array_to_agg function

I've emp table which contains name & name2 field. I need the output in a single line. As i dont have unique id(emp_id) in this table, i am getting error as below :- ERROR: aggregate function ...
Gopal.anant's user avatar
0 votes
1 answer
57 views

Numbering rows in Pandas without order [duplicate]

I have a table Mapping that looks like this Mapping +---------+---------+ | user_id | prod_id | +---------+---------+ | 41 | N12ad | | 2 | nd5Ed | | 73 | bDe4d | | 25 | ...
hokkaidi's user avatar
  • 910
4 votes
2 answers
278 views

In Polars: what is the correct equivalent code for row_number() over(partition by) in BigQuery SQL?

I am trying to refactor (translate) a given SQL query to python script using polars library. I am stuck in one line of query where ROW_NUMBER() function is used followed by OVER(PARTITION BY) ...
Solomon Papathoti Leo's user avatar
0 votes
3 answers
99 views

How do you get ROW_NUMBER to start over at different value between equal values in the partition?

Please see below for what I have and what I would like to have. I have tried a subquery using LEAD and LAG to create a flag for partitioning but couldn't get that to work. Thanks. CREATE TABLE #t (...
plntreltn's user avatar
2 votes
1 answer
104 views

How can I improve performance of this row_number() ranking window function query?

Table user_power_rank: name type pk id string 1 userid integer 0 power integer 0 atime integer 0 Indexes of this table: index name columns i_power_desc_atime_asc power desc, atime asc i_id_power id, ...
Ace.Yin's user avatar
  • 917
0 votes
1 answer
60 views

How can I separate RowNumber counting?

I'm trying to create a point in time hierarchy in my organization. The problem I'm running into are some folks have reported to the same manager more than once in their career. I tried doing a ...
Jason's user avatar
  • 247
1 vote
2 answers
91 views

Check value between multiple rows in SQL

I need to write a query to output a table with 2 values - number & description. Table 1 has 2 columns - id and date id date 101 04-07-2018 102 15-11-...
user3447653's user avatar
  • 4,228

15 30 50 per page
1
2 3 4 5
84