I have the following code However I am unsure what to put in the group by clause as I am receiving this error. ORA-00979: not a GROUP BY expression 00979. 00000 – “not a GROUP BY expression” *Cause: *Action: In the group by , do you have to put the calculation and casts etc. Any help appreci…
Tag: sql
How to get the number of lines if the current times matches between two fields?
ID _From _To Code 1 08:00 11:00 4002138 2 15:00 17:00 4002138 Example 1 Example 2 Please tell me where am i wrong? Answer If you are referring to the current time, then you can use:
In a postgres loop, will the delete actually be performed at the end of the loop?
I need to delete a table, but I want it to be really delete at the end of the loop. Could you confirm that if I code this way, the table will actually be deleted at the end of the loop? the tata table contains data that comes from a CSV, with the COPY. This table is updated every 24
How to find the category that is both ordered & clicked by customer joining multiple tables?
I have these below 5 tables and I am trying to find customers that ordered from the same category they clicked. With a condition where order date should be greater than the click date Table: customers Table : orders Table : clicks Table : product Table : dim Expected results c@gmail will be excluded because h…
SQL deadlock on concurrent delete
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…
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…