Skip to main content
Filter by
Sorted by
Tagged with
4 votes
8 answers
292 views

Starting with the example dat0 below, let's say I want to randomly extract 3 pairs of ìd`s. Initial data (5 id pairs) dat0 <- structure(list(id = c("A", "A", "B", &...
denis's user avatar
  • 972
-1 votes
1 answer
68 views

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
87 views

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
83 views

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
152 views

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
97 views

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,408
1 vote
0 answers
53 views

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
66 views

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
80 views

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
33 views

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
59 views

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
386 views

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
102 views

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
122 views

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
70 views

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
93 views

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
0 votes
0 answers
51 views

I’m getting stumped on this one. I have a data frame that I’m trying to reshape into wide form using pivot_wider, but the results aren’t as expected. My data is currently structured like this: One ...
Kristin's user avatar
0 votes
1 answer
127 views

I am looking for this query to be re-written using sub-queries, top 1 or max function, however due to the nature of data in underlying tables, not able to achieve it. Appreciate if you can help on ...
user20119813's user avatar
1 vote
1 answer
87 views

I am attempting to create a Working Days field in an existing date dimension in SQL Server to extract the nth working day of a month. I have researched solutions so far and have created a field for ...
SarahChapman's user avatar
1 vote
1 answer
111 views

I'm trying to dedupe some large skewed data, of uids, timestamps, and another set of session_ids. The second set of IDs somewhat low cardinality. I'm trying to dedupe the Spark DF across these 3 ...
cpatino08's user avatar
  • 115
0 votes
1 answer
42 views

I have two tables : 1.Actions : Contains multiple actions performed on orderIDs on specific dates. For each orderID, there are multiple rows, each representing a different action performed on a ...
user27265009's user avatar
-5 votes
1 answer
145 views

How to display the serial number for the below select count(*) toatl_count, "employee is Invalid" error from emp union select count(*) total_count, "comapny name is incorrect" ...
praveen's user avatar
  • 27
4 votes
4 answers
134 views

I need to create an id-column: on every TRUE statement it should be a normal serial number, but on every FALSE statement the field value should contain the previous number in this column. In other ...
Watermln's user avatar
1 vote
3 answers
103 views

My table: "letter" "time" "a" "2024-08-14 16:57:56.563112" "b" "2024-08-14 17:57:56.563112" "b" "2024-08-14 18:57:56....
Sergei Suleimanov's user avatar
0 votes
2 answers
55 views

My query records in Clickhouse has about 60m records but when I run in Jupyter it loads only 5000 records. How can I have all records in Jupyter? I need all data of the query result and then make a ...
Pardis Bagheri's user avatar
3 votes
2 answers
601 views

I have the following query in MySQL (version 8+) SELECT MachineId, TotalProduction FROM ( SELECT MachineId, TotalProduction, ROW_NUMBER() OVER (PARTITION BY DATE(InsertedAt) ...
Guilherme Santana's user avatar
0 votes
0 answers
94 views

I have an index.html page showing a table where the results are obtained by DataTables with server-side processing. The results are paginated, and each row has 8 columns: the first column shows an ID ...
m3t4l's user avatar
  • 61
0 votes
1 answer
255 views

I'm writing a query using Querydsl which involves the row_number() window function. The following query works fine: select row_number() over (partition by id) from example_table ExampleTable but as ...
Archmede's user avatar
  • 1,932
0 votes
1 answer
32 views

Based on the InvoiceId, I would like to count 1 to X and add those line item values next to each order line item. Desired result wanted. Adding LineItem column, then counting 1 to X until next ...
paygboy00's user avatar
-1 votes
1 answer
76 views

In the following CTE, outside it, I try to use the RowNum, but it is not recognized. ;with cte as( select * ,min([Close]) OVER(PARTITION BY YEAR(Date),Crypto) AS 'Min' ,max([Close]) OVER(PARTITION BY ...
Kazuo's user avatar
  • 3
1 vote
1 answer
181 views

I have the following A pageheader table A pagecontent table An items table I have a loop that creates a header record in the pageheader, and then a separate insert takes the next 25 records from the ...
Andy Pelton's user avatar
0 votes
1 answer
1k views

I want to find "name_org1" records that are duplicated - no unique records. I am operating in Google Bigquery. To do this I decided to use the ROW_NUMBER() windows function to rank all ...
Bryan-Lee Edwards's user avatar
1 vote
1 answer
69 views

I'm trying to get the maximum value of calories consumed per day. I can't figure out how to get a query result which I imagine to just be 1 row for each date, with a column containing the value for ...
Sidlaux's user avatar
  • 21
0 votes
1 answer
847 views

I want to write below row_number logic in qlik table. How can it be written? row_number() over (partition by job.jobnumber order by cast(hist.EventTimeStamp as Date) asc) as row_id How to write ...
neha ingley's user avatar
1 vote
4 answers
330 views

I have the following in the attachment i tried to use the following macro to obtain the number of row of the first item when i filter this list to "Retail" only. the macro should show a ...
Abby Vilchis's user avatar
1 vote
1 answer
65 views

I am trying to use ROW_NUM() to get me instances of ID's that have only 1 associated comment value which is like 'SEND Final' and that's it. This is an example of the records in a table: Comment ID ...
Krasnips's user avatar
0 votes
1 answer
144 views

I am using Postgres and would like to do a table join on a specific row number. I have the following: LEFT JOIN trip_approver_snapshot tas ON trip.trip_id=tas.trip_id and select * from (select ...
Richard's user avatar
  • 9,005
0 votes
2 answers
1k views

I currently have a dataset, where it is possible for an person to have multiple records in one month, and I only want to take the first. To do this, I am using the row_number function, and my code is ...
jgreggq's user avatar
  • 19
0 votes
1 answer
87 views

I have the data in the following format with several Status codes with their dates. The codes are in question are 3 and 8. I need to find the start date when STcode=3/8 and use it as STDATE and if ...
ckp's user avatar
  • 593
0 votes
1 answer
344 views

I am trying to get an output using SQL Server 2016 that will return StudyID's that only have an AssignmentType of "Final" i.e. no AssignmentType of "Draft". Some studies may have a ...
Krasnips's user avatar
-1 votes
1 answer
122 views

Hi a have a dataframe with some user_id, the months that they are active, and the lead_month which they're active.I need to perform the calculation of column "active_months" shown at the ...
Thais Guerra Braga's user avatar
-3 votes
1 answer
79 views

I am practising with sakila database in MySQL. There is a table name actor with a column last_name. I want to list all last_name which is not repeated in first column, and repeated in second column. ...
Trinh Nguyen's user avatar
0 votes
1 answer
88 views

How to Count(Distinct ID) where the Value is equal 1; possibly using ROW_NUMBER() OVER(PARTITION BY ... ) ?
SamR's user avatar
  • 543
1 vote
1 answer
68 views

I am currently trying to practice with some data manipulation procedures and have faced with the problem of how to make subset based on special condition. Let's assume that the dataframe looks like ...
lenpyspanacb's user avatar
0 votes
1 answer
236 views

I have requirement of selecting data from view with definition of union all of multiple select statements (each table having 500K records) but want to generate row numbers for each of the records. ...
Imran's user avatar
  • 161
0 votes
1 answer
93 views

I'm new to Kusto and I'm trying to fetch top 3 accounts with largest sales amount by sales representative by sales region and I'm struggling to get this right. Imagine a table like this: Sales_rep ...
SusanD's user avatar
  • 143
0 votes
1 answer
35 views

I'm using row_number window function in hive CTE(with clause) with data( select 1 a,1 b union select 1,2 union select 1,3 union select 1,4 ... union select 1,26 ), data_with_row_num ( select a,b,...
Eric's user avatar
  • 118
0 votes
3 answers
165 views

I am trying to create a column that represents how many days ago the most recent promotion started for each product. It should continue counting on when the promotion ended, until the next promotion ...
01010's user avatar
  • 11
0 votes
1 answer
93 views

After searching hours over the internet, still missing a good example of a SQL CTE Query able to be used in real world scenarios, wondering even if CTE and MODERN SQL in general are currently capable ...
ducktype's user avatar
0 votes
1 answer
451 views

I am trying to retrieve the row number along with multiple cell data from a different sheet than the one I am in. I have the query that returns all of the column values I need but I can't seem to ...
Sam Nichols's user avatar

1
2 3 4 5
25