Questions tagged [partition-by]
266 questions
-1
votes
4 answers
SQL Server - Using ROW_NUMBER() OVER PARTITION function to SET a value
Hi everyone thanks for taking some time to look into my question,
Background
I'm using the ROW_NUMER() function along with a PARTITION BY..ORDER BY statement to set a varchar value with an incrementing int value at the end of it for each of a value…

wolly28
- 67
- 1
- 7
-1
votes
1 answer
How to resolve the following mysql query on partition by clause. I believe I am using the clauses correctly
query = """
SELECT
id,
CAST(CAST(ts AS DATE) AS VARCHAR) AS param1,
param2
FROM (
SELECT
id,
ts,
param2_long_name AS param2,
…

user3828311
- 907
- 4
- 11
- 20
-1
votes
1 answer
Iterate through row numbers of a partition and compare values to create new columns in PySpark SQL (spark 2.4.0)
I want to make a loop on row numbers of a partitions in dataframe to check conditions and create extra columns depending on the result of current row_number.
So, i have a dataframe representing contacts with master id <-> raw id association (a…

adamcloud
- 51
- 5
-1
votes
1 answer
In-memory database alternative to HSQL which supports Partition By Query
Working on Spring boot application test-cases. Was mocking Oracle database using hsql in-memory database but found it doesn't support partition by query and fails with below error:
Caused by: org.hsqldb.HsqlException: unexpected token: PARTITION…

nanosoft
- 2,913
- 4
- 41
- 61
-1
votes
1 answer
How to Generate Row number Partition by two column match in sql
Tbl1
---------------------------------------------------------
Id Date Qty ReOrder
---------------------------------------------------------
1 1-1-18 1 3
2 2-1-18 0 3
3 3-1-18 2 …

ManthaN N Patel
- 92
- 1
- 8
-1
votes
1 answer
Select particular result randomly from a table for a certain partition
I want to select record corresponding to 'B' whenever there are duplicates for a name. If there's no duplicate I want to display the record. Refer to the sample table [TableInfo]. Please help me with the SQL query.
TableInfo
Name Type …

SChowdhury
- 163
- 1
- 11
-2
votes
1 answer
Extracting specific value from table in oracle
I have below two tables(Sales and Sales_Status) with below sets of data:
Table Sales holds gather_id and id column. Each id have info status present sales_Status table. I need to frame SQL query in oracle to fetch only those gather_id where…

O_Athens
- 31
- 7
-2
votes
1 answer
Return the 5th column using sql
For a particular date(as shown in image) where the source is only Android, I want to return the 5th column as true else null using sql
I tried using partition statement to answer the problem, but that seems to give me the same records as rnum
-2
votes
2 answers
Get different LIMIT on each group on postgresql rank
To get 2 rows from each group I can use ROW_NUMBER() with condition <= 2 at last but my question is what If I want to get different limits on each group e.g 3 rows for section_id 1, 1 rows for 2 and 1 rows for 3?
Given the following table:
db=#…

A l w a y s S u n n y
- 36,497
- 8
- 60
- 103
-2
votes
1 answer
Oracle 'Partition By' and 'Row_Number' keyword along with pivot
I have this query written by someone else and I am trying to figure out how is it working. I have general idea about all these things such as row_number() , partition by, pivot but I am unable to understand them all together.
For this query…

Shivam Arora
- 476
- 5
- 18
-4
votes
1 answer
Complex SQL Question: Split one record into multiple records based on a value field
We are working with a customer, and the max characters they have for a value field is 10. Therefore, if we have a value record that has more characters than 10, say 50000000.00 (which is 11), the record will be rejected from their system. What I'd…

dehBoy
- 1