Skip to content

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

Need help in framing SQL Query

TABLE-1 OrderDate CustomerNo ProductId Quantity 2021-03-01 1 1 10 2021-03-01 1 3 20 2021-03-02 1 2 15 2021-03-02 1 3 10 2021-03-03 1 1 10 2021-03-03 1 5 25 This table also contains data for other customers also Customers 2,3,4 … TABLE-2 ProductId ProductName 1 P1 2 P2 3 P3 4 P4 5 P5 Products are not Fix…