Skip to content

Tag: sql

Unsure of what to put in the GROUP BY statement

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…

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…

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

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…