EN VI
Posts (0)
Questions (39)
2024-03-12 16:30:07
We can use ROW_NUMBER() here: WITH cte AS ( SELECT Day, CustomerID, Counter, ROW_NUMBER() OVER (PARTITION BY Customer ORDER BY Day DESC) rn FROM yourTable ) SELECT Day, CustomerID,...
Tags: sql
2024-03-12 18:00:05
SELECT * FROM manufacturer WHERE 'Logistics spa' LIKE CONCAT('%', name, '%');
Tags: sql mariadb
2024-03-12 23:30:04
Here is how you can use your query as a subquery and perform the grouping SELECT Name,ID,MaxStatus FROM ( SELECT Name,ID,Status,MAX(Status) OVER(PARTITION BY Name) AS MaxStatus FROM [dbo].[TaskStat...
Tags: sql group-by partition
2024-03-13 00:00:08
As clearly shown in the error message, you can't use window functions directly in an UPDATE, you need a subquery. But you can update the subquery directly, no need to join. WITH cte AS ( SELECT *,...
Tags: sql sql-server
2024-03-13 03:00:06
Why not just select tb.ID, l.LangCode, ISNULL(tbi18n.Content, tb.Content), CASE WHEN tbi18n.ID IS NULL THEN 1 ELSE 0 END AS translationMissing from Languages l CROSS JOIN TextBlock tb LEFT JOIN TextBl...
2024-03-13 10:30:05
You can use a windowed sum function for this: with cte as ( select * , sum(convert(int, IsReleased) + convert(int, IsRequired)) over (partition by id) IsIncluded from testt...
Tags: sql sql-server
2024-03-13 13:00:08
You can start by trying a lot of JOINs. SELECT t1.id AS table_1_id, t31.cost AS cost_1, t32.cost AS cost_2 FROM table_1 t1 JOIN table_2 t21 ON t1.ref_1_id = t21.id JOIN table_2 t22 ON t1.ref_2_id = t2...
Tags: sql
2024-03-13 14:00:04
Assuming that the most recent record would be the one with the greatest created_at value, you could use an INSERT INTO ... SELECT as follows: INSERT INTO users_ill (user_id) SELECT $1 WHERE NOT EXISTS...
Tags: sql node.js postgresql
2024-03-13 14:30:04
I'll assume you are working in a PostgreSQL environment. Simply can do it like this: SELECT * FROM table WHERE null = any(column1) or if null equals to empty string, just change it correspondingly SE...
Tags: sql
2024-03-13 16:00:06
Here is one approach, which uses a LAG() trick to detect when a new block of NULL missing values starts and ends, to be filled in with the non NULL value from that group. WITH cte1 AS ( SELECT t.*...

Login


Forgot Your Password?

Create Account


Lost your password? Please enter your email address. You will receive a link to create a new password.

Reset Password

Back to login