I have a table in Oracle that looks like this: year month customer ———————— 2011 Jan Smith 2011 Jan Smith 2012 Feb Howard 2013 Feb Howard … Now I …
How do I get result from SELECT clause after CREATE and INSERT clause?
I have a query that I intend to put into a stored procedure for ultimate use in Tableau. I am getting affected row(s) instead of the grid result. The query is as follows: IF EXISTS #A DUMP #A CREATE …
Store a list of numbers returned by a query into a variable
I’d like to store the Ids returned by a query like so into a variable: SELECT FooId FROM Bar; — FooId is of type int So that I may later say something like: DELETE FROM Foo WHERE Id IN @…
How to compare two snaps of schema data in SQL?
I have two tables: Current_Ranking: id rank 1 20 2 25 3 26 4 17 Previous_Ranking id rank 1 20 2 26 3 18 4 17 5 5 I want to get as a result all records in …
Working of “between” operator for Varchar and Char datatypes in postgresql
I would like to use “between” operator on “varchar” and “char(5)” columns in a table. However, I don’t see any effect of “between” operator in the results. Please note that “code” is the column name I have a table with a column of type VARCHAR …
Mysql add variable value to result set inside stored procedure instead subquery
This is subquery working fine with required result, now I am writing a stored procedure for the same results. I want to use in stored procedure logic as Declare variables Set them use in …
SQL Server query to group records and insert in other tables
I am using SQL Server database which has tables x, y and mapping table xy. I have a table X with x_id, date, text and receiver id and mapping table xy with x_id and y_id. I need a script to generate …
SQL query help using two WHERE clauses
I have a table with data spanning about two weeks. I want to see the average for the first 7 days and then the next 8. I have tried various JOINS with no luck. I am new to SQL so I am probably …
Search each value of Column A in Column B in SQL Oracle
Let’s say I have this type of dataset: row Num_A Num_B Num_C Reg_1 Reg_2 —— —– —– —– —– —– 1 9400 9500 9700 AAA CCC 2 9700 …
DELETE and NOT IN query performance
I have following table structure: Users UserId (primary key) UserName SomeItems SomeId(FK to Users.UserId) SomeItemId (primary key) Name Other stuff… SomeOtherItems SomeId2 (FK to Users.UserId)…