Questions tagged [union-all]

"UNION ALL" is a keyword in SQL that is used for combining the results of multiple SELECTs. The related tag is "UNION". "UNION ALL" combines the results without checking for Uniqueness. "UNION" combines the results eliminating duplicates.

UNION ALL is a keyword in SQL that is used for combining the results of multiple SELECTs. The related tag is UNION (). UNION ALL combines the results without checking for uniqueness. UNION combines the results eliminating duplicates. The type and order of the fields in the two SELECTs should be the same.

775 questions
1
vote
1 answer

Is there some way to join two of Union All columns

im making League of Legends Api I have items in database like this database I have sql code like this to check how many times ppl bought these items in game SELECT Items.Item, count(Items.Item) as repeats FROM ( SELECT Item0 AS Item FROM…
1
vote
1 answer

MS Access export Union Query to Excel, VBA problems

I am not a programmer but I am building a Access database for work. The database is working ok now, but I am struggling to export one important Query to excel. Thank you for the help and sorry for bad practices and probably many syntax errors. From…
1
vote
1 answer

Use 'UNION ALL' in oracle SQL or not?

I am trying to display employee properties using C# WPF view. I have data in different oracle tables in my DB. Though there are a set of multiple tables, each set consists of the same structure. Those tables structure at high-level is... Tables…
1
vote
1 answer

Calculate Month to date , 6 month and Year to date for Union All Query

I am trying to calculate the month to date and year to date for query created using Union All for two different tables one for receiving and one for sale. They both have the same Vendor name. I have created the query as bellow but can calculate the…
1
vote
2 answers

SQL Server (2008) UNION with ROLL UP

I have an expense report app that collects expense charges and account numbers into one table but a given charges can be split with some portion charged to one GL account and the remainder charged to a different account. The accommodate the cost…
John Joseph
  • 207
  • 2
  • 9
1
vote
3 answers

TSQL: How do I combine two values (money/int) using UNION ALL without changing the data?

I have the following Query: create table #Result (Reward varchar(40), Value MONEY); insert #Result exec GetCurrentCycleQualifierStatusByAccountId @AccountId=76011; with cteFirstResults as (select Reward, round(Value,2) as Value from #Result where…
Jason
  • 463
  • 1
  • 11
  • 25
1
vote
1 answer

Excel VBA SQL UNION SUM with GROUP BY on Tables with Different Column Names

I have two tables, with different column names, as follows: Table Orders: Due Date, Pay, Exchange Rate Table Invoices: Date, Subtotal, Exchange Rate I'd like the following resulting table: Year, Month, Total Where the two tables are UNIONED ALL on…
Mor Sagmon
  • 905
  • 1
  • 16
  • 35
1
vote
0 answers

Hive INSERT INTO vs UNION ALL performance

Lets say I have two tables A and B with same schema and 1 Million rows each, I can add values in table A and B into a table C using either a UNION ALL or two INSERT INTO statements. I actually did it and found that the INSERT INTO did better, but I…
Ani Menon
  • 27,209
  • 16
  • 105
  • 126
1
vote
2 answers

Oracle SQL: in 'WITH' statement, how to avoid empty result row in conditional aggregate function select from different table

I have two tables: CREATE TABLE Test_Persons_A ( PersonID int, LastName varchar(255), FirstName varchar(255) ); INSERT INTO Test_Persons_A (PersonID,LastName,FirstName) values(11,'LN_A1','FN_A1'); INSERT INTO Test_Persons_A …
Stochastika
  • 305
  • 1
  • 2
  • 14
1
vote
2 answers

Single column from Multiple tables SQL-SERVER 2014 Exprs

I have a DB with 50 tables having the same structure (same column names, types) clustered Indexed on the Created Date column . Each of these tables have around ~ 100,000 rows and I need to pull all of them for some columns. select * from…
1
vote
0 answers

Row Bind In sql using UNION ALL

I have multiple subqueries with the same columns (year, week, value). My goal is to have a table with all of the years together My query works, but I have a lot of repetitive code and the query takes a little more time than expected. Am I doing…
Alex
  • 2,603
  • 4
  • 40
  • 73
1
vote
2 answers

joining table with multiple rows and same column name

table 1 id | name | gender 1 | ABC | M 2 | CDE | M 3 | FGH | M table 2 id | name | gender 4 | BAC | F 5 | DCE | F 6 | GFH | F how to make output in oracle database like this : id | name | gender 1 | ABC | M…
harry
  • 9
  • 5
1
vote
2 answers

MySQL UNION ALL gives unwanted value with lead lag

I have a query which is resulting correct values individually. I am seeing where act_in_sec <0 should result no values and that is correct and the problem only arises when i am doing a union all with the same query but different machines. I am not…
s_mj
  • 530
  • 11
  • 28
1
vote
3 answers

MYSQL union All with condition if condition matched choose first else 2nd

In my case it is permissions and roles so i combined result with union all I just want check condition if user permission value = 0 then pick this else other one i am trying like this SELECT username, orgId, uid, pid, perm FROM ( SELECT…
user3712320
  • 116
  • 1
  • 9
1
vote
1 answer

How to pass parameters to mysql stored procedure having union

I'm newbie to MySQL and trying to write a Stored Procedure with IF statement and UNION ALL in Stored Procedure. But I'm not sure where to add Where Condition in the Query. Here I'm trying: BEGIN SELECT 'ele_certificate' AS CERTIFICATE,…
Ganesh Aher
  • 1,118
  • 3
  • 21
  • 51