I am running the following command in Oracle SQL Developer: SELECT order.adate, details.ordid, sum(details.price) as total FROM details,order where details.ordid=order.ordid GROUP BY details….
How to use CASCADE DELETE for removing all tenant data
I want to remove all the entities related to a tenant from the a multi-tenant database when one tenant is removed. I’m working with EF Core and Microsoft SQL Server, although I guess this topic is not …
SQL – copy data from one table column to another table column
As you can see from the image I have a table called wpw8_postmeta where it has four columns and I have searched for the term release and got the following results. I want to copy the results (release_date [meta_value]) to another table called wpw8_test using the post_id as foreign key/primary key. The second …
Redshift SQL statement that will return 1 or 0 if the select statement returns any rows
I have the following select statement in Redshift that will return rows with certain values if the condition inside is met. I want to transform this into a DQ check which will return 1 (True) if no …
how to fetch range of values using LIKE operator in oracle?
I my DB i want to select data which having A15-A19 using LIKE operator but couldnt get required result. the code i made as SELECT * FROM MASTER_RULE WHERE VALUE BETWEEN LIKE ‘A15%’ AND ‘A19%’ and also …
(challenging sql)compare two tables for different value
I want to compare values of table a & c and find differences. We can specify unique_key of table a by compare id between table a & b, and by matching unique_key of table b & c, we can …
Invalid column name grouping by calculated column label
I am trying to run this query to get the sales by month and by account: select left(cast(datekey as varchar(8)), 6) as themonth, account, sum(sales) from Sales where datekey > …
Different SQL query to compare date
I try to grab records from the email table which is less than 14 days. Just want to know if there is a performance difference in the following two queries? select * from email e where DATEDIFF(…
Query to replace ID with Name within the same table?
Can anyone help me figure out this SQL Query? I have the following table: I want the new table to look like this: So essentially I want to replace the third column from “ManagerId” to “Manager Name,” where all information is retrieved in the same table. Can anyone help me with the quer…
How to deal with fixed max number of posts a user can make within a time period?
Sorry for titlegore. Users can have at most 3 active posts, and each post is active for 48 hours. I was thinking about just putting active_post_{1/2/3}_id and active_post_{1/2/3}_expires_at on the users table, but wondering if there is a better way to handle something like this. Answer I would store only the …