Skip to content

Tag: sql

Deleting rows in sql rows based on pair value

I have SQL test table as below: Item Doc_No Code Line_Item 1 abc1234 101 01 2 abc1234 102 01 3 def5678 101 01 4 def5678 102 01 5 ghi1234 101 01 6 ghi1234 101 02 7 jkl5678 101 01 I am trying to eliminate rows when duplicate values of “Doc_No” has pair values of “101” and “102&#822…

How do I perform a dynamic WHERE clause in QuestDB?

I’m looking to create a dynamic WHERE clause in QuestDB for something like the following example SQL: What’s the nicest way to do this? I can’t find guidance in the WHERE keyword documentation Answer This depends on what you’re trying to achieve, but what might be useful is using coale…

Custom Week Number SQL

I need to convert the following logic to python and SQL (SQL query is more imp): I have a table with ID and Date columns. I need to add a column called “Week_Num” such that: Every time it sees a new ID, Week_Num becomes 1 7 dates correspond to 1 week so if the first week begins on 29th Oct