Har bir talaba o’ziga berilgan predmet soha mavzusi bo’yicha HAVING operatoridan foydalanib so’rovlar yaratishi va natijasi bilan ko’rsatib o’tishi kerak
mysql> select count(*) as soni,k_i_raqami,kema_turi from kemalar group by o_soni having soni=1;
+------+------------+---------------+
| soni | k_i_raqami | kema_turi |
+------+------------+---------------+
| 1 | 1 | Yuk tashuvchi |
| 1 | 2 | Kater |
| 1 | 3 | Kuryer |
+------+------------+---------------+
3 rows in set (0.00 sec)
mysql> select count(*) as soni,k_i_raqami,kema_turi from kemalar group by o_soni having soni=2;
Empty set (0.00 sec)
mysql>
Har bir talaba o’ziga berilgan predmet soha mavzusi bo’yicha union, intersect, minus operatorlaridan foydalanib so’rovlar yaratishi va natijasi bilan ko’rsatib o’tishi kerak.
mysql> select * from bazalar;
+------+---------------+----------------------+--------------+
| id | bazaning_nomi | geografik_joylashuvi | qismlar_soni |
+------+---------------+----------------------+--------------+
| 1 | Harbiy | Kaspiy dengizi | 20 |
| 2 | Istisodiy | Orta yer dengizi | 15 |
| 3 | Siyosiy | Arabiston dengizi | 18 |
| 4 | Ekalogik | Kara dengizi | 25 |
+------+---------------+----------------------+--------------+
4 rows in set (0.00 sec)
mysql> select * from qismlar;
+------+---------------+-------------+----------------+-------------+
| id | parcha_raqami | filo_bazasi | joylashgan_joy | harbiy_qism |
+------+---------------+-------------+----------------+-------------+
| 1 | 12 | Harbiy | Karib dengizi | 20-qism |
| 2 | 13 | Jangovar | Bering dengizi | 21-qism |
| 3 | 14 | Maxsus qism | Sharqiy dengiz | 22-qism |
+------+---------------+-------------+----------------+-------------+
3 rows in set (0.00 sec)
mysql> select id from bazalar
-> union
-> select id from qismlar;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
+------+
4 rows in set (0.00 sec)
mysql> select id from bazalar
-> union all
-> select id from qismlar;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 1 |
| 2 |
| 3 |
+------+
7 rows in set (0.00 sec)
mysql>
Do'stlaringiz bilan baham: |