I have an API endpoint to delete children of a parent, unless a child is specified. The SQL is: (This query is sanitised, so ignore the fact that I’m not doing ChildID != @ChildIDToKeep) The executed SQL is also wrapped in a transaction. My web application attempts to send hundreds of requests to this e…
How to pass parameter in PostgresOperator Airflow using for loop
I am using PostgresOperator and I want to pass table name suffix to my SQL query so when it queries the data, it reads dynamically from the for loop iteration So as you can see I have passed .format(country) in task_id. I want to do similar stuff by passing country name like in the below SQL statement but see…
sql query for finding ID numbers on date range
I want to get the ID numbers for the last 24 hour range. Say I run a task at 4:00AM each morning and want to get the previous 24 hours of data going back to 4:00AM the previous day. I need to get the id codes to search the correct tables. If the data is like this what would be
BigQuery/SQL: Split String based on the second dot from right
update: there are situations that dot position that might not be the best solution. I got a column of website. I want to transform it into Anyone knows how to split based on the ‘.’ position from the right? Thanks. Answer regexp_substr() does exactly what you want:
Arithmetic Overflow Error if Varchar is over 999, WHY?
I discovered a weird issue in my database, I was able to fix it, but I do not understand WHY the error occurred in the first place. I’m using Microsoft SQL Server 2017. The following code returns an Arithmetic Overflow error: Returns Error: Arithmetic overflow error converting varchar to data type numer…
How to write a loop for such sql query
I need to write such query: SELECT CAST (date_time_column AS DATE) as ‘Date’, AVG(CASE WHEN FORMAT(date_time_column, ‘HH:mm’) = ’00:00′ then my_values ELSE NULL end) as ’00:00′, …….. AVG(CASE …
Combine 2 GIN indexes with gin_trgm_ops into one | Postgres
I have a flowing table Columns text_id and customer_unit_id basically store codes like K-2021-8524 and similar. In a web interface I use search window to filter out entries by text_id or customer_unit_id. Typical search would be like this I have created to GIN indexes to facilitate search I have tried to make…
Delete all but the newest with specific filename
I migrated a file logger to log to the database instead of to disk. This caused many duplicates in the database, whereas on disk the file would have just gotten overwritten. I want to delete all the “not newest” rows given a specific filename, what SQL would do this given the following table: The …
AttributeError: ‘NoneType’ object has no attribute ’email’. Flask-sqlalchemy
i’ve a strange problem… i do this: and gives me this problem: Who can help me?? thanks <3 Answer it means it didn’t find any users matching your filter
How to sum the minutes of each activity in Postgresql?
The column “activitie_time_enter” has the times. The column “activitie_still” indicates the type of activity. The column “activitie_walking” indicates the other type of activity. Table example: What I need is to sum up the total minutes for each activity separately. Any sug…