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

Remove duplicate rows after UNION ALL in Neo4j

My simple database contains nodes of 'terms' and 'codes' linked to each other. There are two types of relationships. Relationships between 'terms' and 'codes' called :CODE and are undirected (or read in both directions equally). Relationships…
master-lame-master
  • 3,101
  • 2
  • 30
  • 47
2
votes
1 answer

How to make union all command using Yii framework command DAO object

I am trying to make a union of a few tables data into one query using. I am using Yii framework (v1.15). I have done it like this and this worked fine: $command =…
rock-ass
  • 475
  • 5
  • 16
2
votes
3 answers

Group by & Union In Sql

I am very much confused about this GROUP BY & Union statements. Right Now I am getting this O/P. But I want my output to look like this: Vendor Name Purchase Order Req Qty Inward Qty …
Hardik Parmar
  • 1,053
  • 3
  • 15
  • 39
2
votes
4 answers

Why using OR condition instead of Union caused a performance Issue

Hi I have below query in an SP @CrmContactId is a parameter to the SP. Select distinct A.PolicyBusinessId, A.PolicyDetailId from TPolicyBusiness A inner join TPolicyOwner B on a.PolicyDetailId=b.PolicyDetailId Left Join TAdditionalOwner C on…
Bhaskar
  • 1,680
  • 7
  • 26
  • 40
2
votes
1 answer

Linq union all equivalent of sql code

I have the following queries: var majorClients = maj in dbContext.MajorClients where (maj.startdate > startDate) where (maj.status == "Active") Select new Client{EntityPK =…
breakerdotnet
  • 93
  • 1
  • 11
2
votes
1 answer

Access UNION query yields unreadable results when Null row precedes other data

I have an Access 2013 database with a table named [carInsurance] as follows: Now I want to display all the data in this table along with an "empty" row full of NULL values. So I use a UNION query to accomplish that as follows: select NULL as…
Hilal Al-Rajhi
  • 437
  • 6
  • 25
  • 49
2
votes
2 answers

inner join and union all using order by

I have this query: SELECT B.IMAGE_ID as image_id_fav,I.Image_Path as image_path_fav FROM Buddies B INNER JOIN @favDT F ON F.favorite_id = B.Reg_ID and b.favorite_id=@regID INNER JOIN Images I ON I.Image_ID = B.Image_ID where b.Image_ID >0 union…
User7291
  • 1,095
  • 3
  • 29
  • 71
2
votes
1 answer

ssis how to automatically get all columns for union all

I have about 20 data sources to union in current packages. When using "Union All", it will import columns from the first connected data source. Then I have to manually add columns from other 19 data sources which are not contained in the first one.…
Echo
  • 1,117
  • 4
  • 22
  • 43
2
votes
2 answers

UNION ALL - but with non-simultaneous execution of its parts

I'm trying to perform an aggregation over a large set of manually "partitioned" tables. I can do it with T-SQL of the following style. SELECT A, B, C, COUNT(*) FROM ( SELECT ... UNION ALL SELECT ... UNION ALL SELECT ... -- and many…
dsz
  • 4,542
  • 39
  • 35
2
votes
1 answer

recursive WITH clause must reference itself directly in one of the UNION ALL branches

The following query is giving error : recursive WITH clause must reference itself directly in one of the UNION ALL branches insert into tt_q_items WITH CTE ( REFUND_TRANSMISSION_QUEUE_KEY, FINANCIAL_REFUND_REQUEST_KEY, …
2
votes
1 answer

Materialized View involving UNION ALL operator in FROM with ON COMMIT

I have two tables 'survey' & 'survey_processed' and both are basically similar tables. I have a working query which uses UNION ALL operator between two tables & am getting some counts. When I try to translate it in to a Materialized View, I get the…
Curtis
  • 55
  • 1
  • 2
  • 5
2
votes
2 answers

which one should i used of Union all and union when i want to eliminate the duplicate records?

As title. i have seen this, people all saying that we should consider union all first for the performance, my question is which one should i use when i want to eliminate duplicate records. i have seen that developer use union all to search the…
Jimmy Chan
  • 199
  • 2
  • 6
2
votes
1 answer

Union all - 3 tables, 2 will never contain duplicates, the other will

I know the union all questions gets asked a lot, but I have a slight variation. I will be doing a union all on three different queries/tablesets. The first 2, by definition of their queries, will never have duplicates, but the third will…
Ryan Ward
  • 1,523
  • 4
  • 15
  • 23
2
votes
1 answer

Using OPENQUERY with a table created on the fly

I have a four-part linked server query that LEFT OUTER JOINs a table created on the fly using UNION ALL, something along these lines: SELECT t.column1, rlt.s6, SUM(t.column3) column3 FROM Linked_server.database.schema.table t LEFT OUTER JOIN ( …
Wade
  • 418
  • 4
  • 9
2
votes
2 answers

MySQL Get COUNT from combined multiple fields

Say I have a table: user_id parent_id lev1 lev2 lev3 lev4 1 0 0 0 0 0 2 1 1 0 0 0 3 1 1 0 0 0 4 2 2 …