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
2
votes
1 answer

PySpark Working with Delta tables - For Loop Optimization with Union

I'm currently working in databricks and have a delta table with 20+ columns. I basically need to take a value from 1 column in each row, send it to an api which returns two values/columns, and then create the other 26 to merge the values back to the…
dcrowley01
  • 141
  • 2
  • 12
2
votes
1 answer

with cte union all select

I have two tables Arrears and Invoices . I am trying to do the following: ;with Acc.. as ( select ....from ....) select ..... from Arrears UNION ALL select ... from Invoices the problem is that results are like : A header B…
2
votes
4 answers

how to sum two columns from different tables MySQL

I need to sum the data from two different columns located in different tables and grouped by session_id..... I need to sum the column of spent_points + price_points grouped by session_id this is the result i hope to get I have tried with this…
2
votes
4 answers

Union All but keep only duplicates from one table in T-SQL

I have two table which I would like to union. I need to keep only the duplicates from one of the two tables. I tried to find it, but could not find it anywhere. Hope somebody can help. For…
xris23
  • 353
  • 1
  • 8
2
votes
1 answer

What is the difference between union and union all in SQL?

Difference between union and union all?
2
votes
2 answers

union results of multiple queries with different number of columns in SQL Server

I am writing SQL to report data similar to the below format. The row's beginning with 'P' are summary rows for a specific vendor for the corresponding remittance 'R' rows below it associated to the payment or that vendor. For example the PAID_AMT…
Nick
  • 268
  • 8
  • 33
2
votes
2 answers

In BigQuery, identify when columns do not match on UNION ALL

with table1 as ( select 'joe' as name, 17 as age, 25 as speed ), table2 as ( select 'nick' as name, 21 as speed, 23 as strength ) select * from table1 union all select * from table2 In Google BigQuery, this union all does not throw…
Canovice
  • 9,012
  • 22
  • 93
  • 211
2
votes
0 answers

Transform table to create new column using records of another columns

I have following tables in PostgreSQL 11 name a a_code b b_code 4-aminopyridine aminopyridine N07XX (null) (null) abacavir sulfate abacavir sulfate …
rshar
  • 1,381
  • 10
  • 28
2
votes
1 answer

How to achieve a similar result as OUTER UNION CORR in Hive SQL?

I am trying to create a table by combining multiple tables, but I need to get all columns on my output table. Create table output_table Select cl1, cl2, cl3, cl4 From table1 Union all Select cl1, cl2, cl3, cl5 From table2 Union all Select cl1, cl2,…
Saye
  • 33
  • 3
2
votes
1 answer

Getting Inconsistent result while using UNION ALL with CTEs in Impala

Has anyone ever faced data consistency issue while using UNION ALL with CTEs in impala. I have two CTEs T1 and T2 . T1 has 264 distinct rows and T2 has 35 distinct rows. T1 UNION ALL T2 is giving me just 56 rows but logically it should be returning…
Kishan Pandey
  • 191
  • 1
  • 8
2
votes
1 answer

horizontal UNION ALL

I have two tables and I need to select one column from each of them. This must be done in a single query. The good news is that the two columns are ordered the right way and they both contain the same number of rows. Now, I know I could JOIN the two…
Petr
  • 1,128
  • 2
  • 14
  • 23
2
votes
0 answers

PHP MySQL How to select 2 specific and 1 common value over 2 tables?

i have here two tables (only the important columns listed) : table1: unique_code(INT), spediteur(VARCHAR also Names), table2: unique_code(INT), versendet(timestamp) I have here a SELECT but that don't work and if the value is true - that means:…
kay_device
  • 33
  • 5
2
votes
2 answers

SQL UNION ALL query returning all Null values in date field

I am trying to split one datefield column into three target columns, depending on a status column: My table1 is as follows: **id status DateField** 1 A 1/5/2018 2 B 1/6/2018 3 C 1/7/2018 So I am trying…
data_analyst
  • 27
  • 1
  • 4
2
votes
1 answer

Force parallel union execution

I have a query that collects data from six tables of the same type. To create the final selection, I use UNION ALL. Unfortunately, the optimizer scans each of the six tables in turn, and then collects into one. Is there any way to make the optimizer…
user2996299
  • 123
  • 3
2
votes
2 answers

How to compare two mysql tables?

I am new in mysql. I have two completely identical mysql tables (they have similar id). Table_1 +----+------------+------+ | id | group_name | cell | +----+------------+------+ | 1 | YE-04 | 12 | | 2 | AG-11 | -200 | | 3 | VG-17 …
David Grigoryev
  • 125
  • 1
  • 11