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

BigQuery: Union on repreated fields with different order of fields

How to make a UNION ALL work for repeated fields if the order of the fields does not match? In the example below I try to UNION data_1_nested and data_2_nested, while the repeated field nested has two fields: id and age but in different order. I…
Ilja
  • 993
  • 2
  • 17
  • 36
1
vote
0 answers

Anomaly foundd using UNION ALL, GROUP BY, using subquery

Well, I'm pretty new on teradata, but I'm pretty sure I can understand this simple logic, except I took the logic wrong, so here's the case : I have one table in Teradata database with some records in it, this record was imported daily from txt file…
KarsaZ
  • 13
  • 3
1
vote
1 answer

Support UNION ALL function in BigQuery SQL Issue

How can i make this query run on GCP big query without error: 'Correlated subqueries that reference other tables are not supported unless they can be de-correlated, such as by transforming them into an efficient JOIN.' Do you guys have any ideia…
1
vote
2 answers

Making a query to merge two tables upon criteria, with giving priority to the rows from the second table

I’ve got two MS Access tables. table1 ID Country Dat Val 1 Australia 01.10.2021 10 2 Canada 01.10.2021 100 3 Japan 01.10.2021 1000 4 Australia 02.10.2021 20 5 Canada 02.10.2021 200 6 Japan …
ZolVas
  • 190
  • 2
  • 16
1
vote
2 answers

Transform `SELECT` .. `UNION ALL` `SELECT` .. into something more efficient?

I have following query, which works, but I guess it can it be improved to something more efficient, how to do it? all the values are from 1 table 1st part of the result are always 2 rows having some a relation forming 1 row with all the fields…
Lukas Salich
  • 959
  • 2
  • 12
  • 30
1
vote
1 answer

create view with union all using select not working

I have below query where i am getting error as ORA-00979: not a GROUP BY expression and also logically its not working. Normally the logic should be for every FUND_ISIN check the value for member_descr. If for FUND_ISIN the member_descr != 'O' or…
Symonds
  • 184
  • 1
  • 2
  • 15
1
vote
3 answers

SQL Merge rows instead of UNION ALL

I'm doing a UNION ALL to get the results as shows in the table below. This approach is causing to have unnecessary rows. The three columns DESK, SEGMENT and SUPERVISOR are independent and have no relationship. Code SELECT ID, DESK, '' as SEGMENT, ''…
shockwave
  • 3,074
  • 9
  • 35
  • 60
1
vote
1 answer

BigQuery - Union All tables in a dataset

I have a dataset in BigQuery where I upload a new table every 2 days. All tables are the same. Want to write and schedule a query than Union all tables, including when a newone is uploaded to the dataset. Using the below one and is working, however…
1
vote
1 answer

Outer and union all on the same table?

I have recently faced a query which has been written longtime ago for an Informix database. This query seems a bit strange and nonsense to me. I know This query returns all the rows from the city table with the rows that match in the ocw table. If…
itro
  • 7,006
  • 27
  • 78
  • 121
1
vote
1 answer

How to count, for every table, distinct values in a column that is shared by an unspecified number of tables in SQL Server?

I have a fluid and indeterminate number of views in a SQL Server database with a column called "CONFIDENCE". For every view in that set, I would like to count how often distinct values turn up in that column. I know how to find all views that have…
jesnes
  • 157
  • 7
1
vote
1 answer

ERROR: Column >>?column?<< specified several times

when I execute the following UNION ALL code to combine several tables into one materialized view I get the error: column >>?column?<< specified several times. As you can see above the code, i strictly hold on to the sequence from the original…
1
vote
1 answer

Combine two tables into one materialized view

i am trying to combine two tables (POIs) into one materialized view but they don't have the same columns. For example: Table a: attributes: name, type, geoloc, symbolnumber Table b: attributes: name, type, info1, info2, geoloc I tried "JOIN" and…
1
vote
2 answers

UNION ALL not combining rows

I have this table called "valores_indices" where it imports stocks values every 1 hour, I need to get the values from each monitored stock at 8am and 6pm, those being respectively my "vlrAberto" and "vlrFechado" selects I don't get why these are not…
Nimm
  • 15
  • 8
1
vote
2 answers

How to populate UNION ALL query data in html table

how can I populate data in html table with both side header fetched with PHP and MYSQL.I am not getting the output display, As I want to get, like in the desired output image. $query = $db->prepare("SELECT player, score FROM cricket_table WHERE…
Eniol
  • 77
  • 12
1
vote
3 answers

How to club all values of MySql?

I am using UNION ALL to club the values. SELECT COUNT(*) as votesfromIndia FROM voting WHERE MobNo LIKE '91%' UNION ALL SELECT COUNT(*) as votesfromUS FROM voting WHERE MobNo LIKE '1%' UNION ALL SELECT COUNT(*) as votesfromBelgium FROM voting WHERE…
golie
  • 11
  • 3