UNION  SQL. 18    
 


   UNION  UNION ALL  SQL     .  18    :  ,  ,  ,   ,  ,  ,    ,        .     SQLite,     .





 

UNION  SQL. 18    





  





  UNION


UNION ,         ,        .

 :    ,    ,    ,    .

  : UNION  , UNION ALL  .        ,    .




   


   UNION        .    ,   .

       .     ,     .

     source.   UNION ALL ,    .




  


1.      (#task-1)

2.    UNION ALL (#task-2)

3.     (#task-3)

4.      (#litres_trial_promo)

5.     (#litres_trial_promo)

6.      (#litres_trial_promo)

7.    UNION ALL (#litres_trial_promo)

8.     UNION (#litres_trial_promo)

9.     (#litres_trial_promo)

10.      (#litres_trial_promo)

11.      (#litres_trial_promo)

12.    (#litres_trial_promo)

13.     (#litres_trial_promo)

14.    UNION ALL  GROUP BY (#litres_trial_promo)

15.       (#litres_trial_promo)

16.      (#litres_trial_promo)

17.    (#litres_trial_promo)

18.       (#litres_trial_promo)




 





 1.     



 

    email        .




CREATE TABLE buyers_2025(email TEXT);

CREATE TABLE buyers_2026(email TEXT);

INSERT INTO buyers_2025 VALUES ('anna@example.test'),('oleg@example.test');

INSERT INTO buyers_2026 VALUES ('oleg@example.test'),('nina@example.test');




SELECT email FROM buyers_2025

UNION

SELECT email FROM buyers_2026

ORDER BY email;


 

[["anna@example.test"], ["nina@example.test"], ["oleg@example.test"]]


 

UNION     SELECT.

 oleg@example.test   .

ORDER BY      .


  

UNION  .       ,      .


 

 oleg@example.test   ,      ?

:   UNION     .




 2.    UNION ALL



 

        ,    .




CREATE TABLE sales_day1(id INTEGER, total INTEGER);

CREATE TABLE sales_day2(id INTEGER, total INTEGER);

INSERT INTO sales_day1 VALUES (1,500),(2,300);

INSERT INTO sales_day2 VALUES (3,500),(4,200);




SELECT total FROM sales_day1

UNION ALL

SELECT total FROM sales_day2

ORDER BY total DESC;


 

[[500], [500], [300], [200]]


 

UNION ALL    .

   500   .

     .


  

  UNION ALL  UNION,     500   .


 

      UNION ALL ,  UNION?

:      ,         .




 3.    



 

      ,  ,    .




CREATE TABLE site_leads(email TEXT);

CREATE TABLE form_leads(email TEXT);

INSERT INTO site_leads VALUES ('a@example.test'),('b@example.test');

INSERT INTO form_leads VALUES ('b@example.test'),('c@example.test');




SELECT 'site' AS source, email FROM site_leads

UNION ALL

SELECT 'form' AS source, email FROM form_leads

ORDER BY email, source;


 

[["site", "a@example.test"], ["form", "b@example.test"], ["site", "b@example.test"], ["form", "c@example.test"]]


 

 SELECT    source.

UNION ALL   email   .




  .


   .

   ,     (https://www.litres.ru/book/raznoe/union-v-sql-18-zadach-na-ob-edinenie-tablits-74419702/)  .

      Visa, MasterCard, Maestro,    ,   ,     ,  PayPal, WebMoney, ., QIWI ,       .


