I need a stored procedure to select rows from one table, do a Group By, Sum, and then insert the results into another table with their values. I guess I’ll have to do a merge when …
Tag: sql
Cloning tree structure with guid
I am trying to clone tree structure to another table, but the problem is original table has guid as ParentId and Id and new table or table that I want to clone has int as ParentId and Id. I am trying …
Select all completed months until certain date in SQL Server
I have a query that returns certain time series information. But since I am doing analysis for each completed month, I would like to ignore the last month information so it does not contaminate the …
Recursive query design – Oracle SQL
I am looking to create a recursive query that is able to completely map a series of replenishments, to a top level requirement. Below is some detailed information regarding my problem statement: I …
INSERT INTO failing on SQL Fiddle
I am trying to create a SQL Fiddle for creating a test database. My query is below: — schema CREATE TABLE tblInputs ( Type VARCHAR(256), Order_No VARCHAR(256), Planned_No VARCHAR(256), …
Smart way to write where col1 = x OR col2 = x on ALL the columns in SQL
Suppose I have 100 columns and I want to search for something but I don’t know which column to search. How can I write a loop that: SELECT * FROM table WHERE col1 = ‘x’ OR col2 =’x’ OR col3 = ‘x’ …
DB2 – Using Running totals to calculate Month To Date Sales
I’m calculating the Month to date sales using DB2 code to compare July 2019 vs July 2018 totals. It needs to be rolling to compare the current month of data to the same month last year, otherwise I …
sql left email till @ symbol
i have a column called Email in my sql database so i need to left my column to get whats before the @ symbol
SQL Inner Join returns duplicates
I have the following 2 tables: tab1 with 37146 rows week_ref with 730 rows All I want to do is join those tables on year and week so that the first week day and last week day will display next to …
MSACCESS returning NULL values where textbox = “blank”
I have a search query that returns values from textboxes. I want to add the functionality to return all rows where Comments is null or empty. I have tried editing the SQL to accept “blank” in the …