I’m trying to keep a historic table of another one. When updating the original I would like to insert rows into the historic one. I’m using Sql Merge: Can I make multiple statements in the same “when” condition?, as such: Answer Normally you can INSERT only into one table. The syntax d…
Can I combine more than one function in a single line in SQL?
What I want to do is simply to use more than 1 function in a single query. I’m new to SQL so I’m sorry if I’m getting some words wrong. select cognom from emp where length(cognom) = 10, replace(cognom, ‘ ‘, ‘*’); Answer Yes, you can, as long as you respect the syntax.…
Find Stored Procedure By Table Name (Oracle)
Need help. Every morning at 4 o’clock a table is created in the database, I need to understand what sources are used to create it, so I tried to find a stored procedure that creates this table using all_source or dba_source (select * from all_source where upper(text) like ‘%TABLE_NAME%’, but…
Search SQL database with multiple filters
I have the following code: This gives me the rows where “category_id” is equal to the 1. I now want the SELECT statement to return rows where the “category_id” is equal to one of the values I give it. So a simple SELECT statement would look something like this The problem is that I wou…
SQL query for last 365 days report
I have a reports table with the following structure : I want a SQL Query to get the report for the last 365 days by following conditions : Group dates if the same date is repeated. The days which the report is not available for the last 365 days, I need those days added to the result rows with 0
How to calculate sum of a value with only “day of week” using a date-range?
I have 2 tables namely Item table with details of item_id, store_id, offer_start_Date and offer_end_date Store table has store_id, day_of_week, store_hours The structure of both tables are follows – 1) Item_Table : Store ID Item ID offer_start_Date offer_end_date NY0001 FMC0001 2021-10-30 2021-11-04 NY0…
How can I query the results of a MySQL query and get a COUNT() of the results that fall within a certain range?
thanks for taking the time. I have the following query: Which gives me the results I want which are the distinct ‘bike_id'(as there are no duplicates), the count of all the rides each ‘bike_id’ made in 2017, and the quick average for the year for each ‘bike_id’. From here, id lik…
Removing count column from query output
Bsically, I’m trying to get the top 5 most rented but don’t want the actual count column as output only as a means of ordering the output. Is this possible? Answer You can try remove the count column and give the formula to order by part: My test: Select for MS SQL Server 2017: Output: col1 A B
Trigger in SQL causing error “Product_Reorder is not a recognized SET option”
I am not getting a syntax error syntax error near ; This is referring to the ; at the end of the code. Answer Not 100% sure what you’re trying to do – you’re not giving us much to go on, either! I’m assuming you mean you want to set a column called Product_ReOrder in your table to 1 if
Check if string contains user-defined substring using SQL LIKE operator
Basically I have a table like this: movieId name 1 White chicks 2 Inception 3 The Avengers: Endgame 4 Avatar: The Last Air Bender My job is to retrieve all relevant movies based on a substring of the movie name. For example, if a user enters a substring such as “av” (e.g., they enter “http:/…