So I have a database with more than 2000 line and I wanted to delete the duplicate value based on 2 rows.For Example : no server name 1 serv1 a 2 serv1 b 3 serv1 …
More than 24 hours in a day in postgreSQL
Assuming I have this schema: create table rental ( id integer, rental_date timestamp, customer_id smallint, return_date timestamp, ); Running this query returns strange …
SQL Server Information_Schema
I want to check a table’s primary key by SQL statements, I use below SQL: SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE = ‘PRIMARY KEY’ AND TABLE_NAME = ‘…
Already inserted data replace into another UserId
In my Business unit table FK is the UserId ex: UserId =001, BusinessUnit = Bangalore ex: UserId =001, BusinessUnit = Hyd …. Now, I need UserId = 002 is different I want to create same data into 002 The INSERT statement conflicted with the FOREIGN KEY constraint “FK_UserAccess_UserDetails”. T…
My SUM with cases seems to be repeating twice
I have some camp management software that registers users for a camp. I am trying to get how much a user owes on their account based on how much a camp costs and whether they are using the bus, and …
SQL Function inside of where clause to see if field is in concatenated list (from parameter)
I have these two lines ,SUM (CASE WHEN (DATEDIFF(DAY,Shopify_Ordered,Confirmed) >= 1)THEN 1 ELSE 0 END) OVER () Orders1DayNotShipped ,dbo.GROUP_CONCAT( (CASE WHEN (DATEDIFF(DAY,Shopify_Ordered,…
A reverse IN statement?
I feel like I am either overthinking this or it’s not possible but is there a way to do something like a reverse IN statement in SQL? Instead of saying: WHERE column_name NOT IN (x, y, z) I want to …
How to execute a native SQL query having INTERVAL clause through Spring Boot JPA?
Not able to execute a native SQL query through Spring Boot Repository layer with JPA in Oracle DB I am trying to write a native SQL query that gets data from a table between the current date and last …
How to write Inline If Statement(SQL IIF) in EFCore Select?
I have the following Customer table: Id First Last LocationId 0 John Doe 2 1 Mary Smith 4 My use case requires column level permissions(predicated on a value in the Entity’s …
MYSQL – max(id) pulling correct id but incorrect related data [closed]
I’m trying to get the latest data from a table based on a join. I’m having trouble getting it to return anything but the first record, (old data). The temp_table would just have a listing of …