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
votes
2 answers

Alternative option to UNION ALL

I have the SQL below: SELECT '1.1' AS column_a, '1' as column_b, 4 AS column_c FROM SYSIBM.SYSDUMMY1 UNION ALL SELECT '1.2' AS column_a, '1' as column_b, 4001 AS column_c FROM SYSIBM.SYSDUMMY1 UNION ALL SELECT '2.1' AS column_a, '2' as column_b, 1…
Daniel Barral
  • 3,896
  • 2
  • 35
  • 47
-1
votes
2 answers

Combining column values from different tables

I stuck. I have 2 tables - look at image no.1 Table columns And i would like to build query, that will give me the result - it is showed on image no 2. the result of query. I have 2 queries and I would like to mix them up, to obtain the list from…
Radi Em
  • 1
  • 4
-1
votes
1 answer

SQL server query UNION ALL

I have a UNION ALL query that I'm getting incorrect results for. I'm supposed to get about 1100 hundred records. Please see query... select Pop, planID, PopFull, ApptDate, intake1,FollowUP2,FollowupCode, rn, '5133' from (Select *,…
FatBoySlim7
  • 232
  • 1
  • 2
  • 13
-1
votes
1 answer

SQL Server query assistance needed

I'm storing a bunch of data in a view (converted MS Access queries to views). Now what I'm trying to do is write a stored procedure to pull data based on when the data was added. Here is the query that I'm running Select Name, PlanID, ApptDate,…
FatBoySlim7
  • 232
  • 1
  • 2
  • 13
-1
votes
1 answer

SQL join two similar tables

I have two similar tables: SELECT * FROM CTP0002; SDKEY SDNAME 2 Hello 4 World SELECT * FROM CTP0003; SSKEY SSNAME 3 Name1 6 Name2 And i want this result: SDKEY SDNAME 2 Hello 4 …
-1
votes
1 answer

Getting 'conversion failed...' when using UNION ALL, but running the queries separately works

I am trying to use SELECT INTO and UNION ALL to join 3 tables together. Table 1 uses a number of Ltrim(Rtrim()) and CONVERT commands, whilst with the other two tables, I am just taking their columns out and pasting them into this combined…
elbarto
  • 211
  • 3
  • 15
-1
votes
2 answers

Mismatch of columns in UNION ALL statement

I have this query, (SELECT [NAME], [NAME] AS RESULT, ' - ' AS VALUE, 0 AS ORDERING FROM [PARTY_MSTR] UNION ALL (SELECT …
DhavalR
  • 1,409
  • 3
  • 29
  • 57
-1
votes
1 answer

Calculate days difference between two dates from two queries conslidated by union

I have two queries with a union all between them. I am trying to calculate the differences between two dates, one of them in the 1st query, and the other is in the 2nd query. The 1st date in the 1st query is t0.duedate, the 2nd date in the 2nd…
-1
votes
1 answer

How can I use UNION ALL concept in different way in SQL

I have one SQL query which i mentioned below, but i have used UNION ALL which is taking more time to execute. But i want some different approach to get the same details which will be more efficient. Please help me on this. …
user2642751
  • 43
  • 1
  • 9
-1
votes
1 answer

How to use SQL UNION operation

SELECT a.* FROM tableA AS a LEFT JOIN tableC AS c ON c.id = a.catid LEFT JOIN tableD AS d ON d.id = a.created_by INNER JOIN tableE AS e ON e.content_id = a.id WHERE a.access IN (1,1,5) AND c.access IN (1,1,5) I am trying to…
Nadeeshaan
  • 356
  • 5
  • 15
-1
votes
1 answer

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

Can anyone please tell me the difference where to use union and where to use uinon all in mysql
Ankit Gupta
  • 189
  • 12
-1
votes
1 answer

How to sort using UNION ALL and ORDER BY using SQLite

I have Some data in SQLite database in android. I want to retrieve data from database using WHERE clause Using LIKE and NOT LIKE Conditions. I am combining two statements using UNION ALL Command. For that the queries are SELECT * FROM TABLENAME…
Charan
  • 63
  • 1
  • 3
  • 9
-2
votes
1 answer

Create pivot table from 3 tables using SQL

I am trying to join three tables to then create a pivot table. I'm struggling to find figure out how to do this. Below is an example of the format of the three existing tables and the desired out output table. I am working in Tableau and the data is…
Data Team
  • 13
  • 2
-2
votes
3 answers

If a column is not null then convert into a row for multiple columns

I have a table like below where I looking to transpose col4 col5 and col6 into rows but in a specific pattern that I listed below col1 col2 col3 col4 col5 col6 a b c 500 200 w x y 1000 300 z g h 200 600 I want to convert it to the…
msv
  • 15
  • 3
-2
votes
2 answers

How to find out duplicate records from multiple tables in MS Access based on two condition

How to find out duplicate records from multiple tables in MS Access based on month and the below columns ? Name, Text, Description, TestDescription select [table1].[Name], [table1].[Text], [table1].[Description], [table1].[TestDescription] From…
Ibra
  • 7
  • 3
1 2 3
51
52