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

SQL Server combine rows and columns

please help, I'm starting to learn sql and I have to combine all 3 authors in one row. how can I remove the dups and only show one result? with cte_authors (titleID, Authors, lvl) as (select distinct titles.title_id,…
-2
votes
1 answer

UNION ALL View Running terribly slow

I am prepping data for vizualiaztion in Tableau. Currently, we have about a dozen tables, with some shared values, that I am combining into one large view via a huge UNION ALL script (attached showing 2 tables only) My performance in Tableau is…
-2
votes
3 answers

GROUP BY clause error in a SELECT UNION ALL ORDER BY query

I am trying to sort a table after a union all in SQL SERVER I have read in several places (here for example: How to use order by with union all in sql?) that I need to write : SELECT * FROM ( SELECT * FROM TABLE_A …
Lili
  • 55
  • 1
  • 2
  • 10
-2
votes
1 answer

Combine Two table datas

I have two table A and B, i need a report by combining these two tables and the output should be as below image. How can i achieve it. Please help me out.
Subbu
  • 41
  • 1
  • 8
-2
votes
1 answer

joining three tables in sql using union all

CREATE TABLE ZIPCODE_16P2 ( ZIPCODE NUMBER (10) NOT NULL, CITY VARCHAR2 (50) NOT NULL, STATE VARCHAR2 (50) NOT NULL, PRIMARY KEY (ZIPCODE) ); CREATE TABLE REGISTER_LSP_16P2 ( LAB_ID NUMBER (10) NOT NULL, PASSWORD …
-2
votes
1 answer

inner join VS union all, when the result is not found

I have two tables with the same column name. I want to search in them.I've research and realized that using UNION ALL is better that INNER JOIN (in terms of speed and performance). Now i want to know if the result is not found, UNION ALL is better…
Shafizadeh
  • 9,960
  • 12
  • 52
  • 89
-2
votes
2 answers

I want to insert multiple rows into SQL Server database, but get syntax errors

I want to insert multiple pieces of data into a SQL Server database as shown below, but when I run this code, I get a syntax error Incorrect syntax near the keyword 'union'. Incorrect syntax near ''. Incorrect syntax near ''. Incorrect…
user3838676
  • 3
  • 1
  • 3
-3
votes
2 answers

How can i use ORDER BY with UNION ALL in a sql query?

I have problems with ordering the results of a query that joins 4 different tables with UNION ALL operator. What I have tried is something like this: SELECT * FROM ( SELECT charge, payment, date FROM table_1 UNION ALL SELECT charge, payment, date…
estebanovic
  • 106
  • 6
-4
votes
2 answers

Why is UNION ALL causing errors and how do I join my datasets?

I have similar datasets to the following TABLE1 Column1,Column2,Column3, ID1 ,ID2 ,Value1 TABLE2 Column1,Column2,Column3, ID3 ,ID2 ,Value2 I would like to get TABLE3 Column1,Column2,Column3 ID1 ,ID2 ,Value1 ID3 ,ID2 …
-6
votes
1 answer

Read data from two tables

Consider the tables listed below Table credit id cr_amount created_date 1 1000 2011-07-01 2 2000 2011-07-08 3 6000 2011-07-09 And Table debit entries are follows. id dr_amount created_date 1 3000 …
Mable John
  • 4,518
  • 3
  • 22
  • 35
1 2 3
51
52