Created
February 11, 2017 05:38
-
-
Save xypnox/0d7b9c92fb9343b76d1b18597a3534d1 to your computer and use it in GitHub Desktop.
SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> use trade; | |
Database changed | |
mysql> select * from mall; | |
+------+-------------+-------+---------+------------+ | |
| code | mname | owner | city | no_of_mall | | |
+------+-------------+-------+---------+------------+ | |
| 111 | FUN | XYZ | DELHI | 3 | | |
| 222 | PVR | ABC | LUCKNOW | 8 | | |
| 333 | WAVE | XYZ | KANPUR | 3 | | |
| 444 | CITY CENTER | XYZ | DELHI | 4 | | |
| 555 | GLOBE | ABC | LUCKNOW | 6 | | |
+------+-------------+-------+---------+------------+ | |
5 rows in set (0.05 sec) | |
mysql> select city from mall where owner like "ABC"; | |
+---------+ | |
| city | | |
+---------+ | |
| LUCKNOW | | |
| LUCKNOW | | |
+---------+ | |
2 rows in set (0.00 sec) | |
mysql> select mname from mall where mname like "w%"; | |
+-------+ | |
| mname | | |
+-------+ | |
| WAVE | | |
+-------+ | |
1 row in set (0.00 sec) | |
mysql> select code, mname from mall where no_of_mall > 2 and no_of_mall < 6; | |
+------+-------------+ | |
| code | mname | | |
+------+-------------+ | |
| 111 | FUN | | |
| 333 | WAVE | | |
| 444 | CITY CENTER | | |
+------+-------------+ | |
3 rows in set (0.02 sec) | |
mysql> select city, sum(no_of_mall) from mall group by city; | |
+---------+-----------------+ | |
| city | sum(no_of_mall) | | |
+---------+-----------------+ | |
| DELHI | 7 | | |
| KANPUR | 3 | | |
| LUCKNOW | 14 | | |
+---------+-----------------+ | |
3 rows in set (0.02 sec) | |
mysql> select distinct(owner) from mall; | |
+-------+ | |
| owner | | |
+-------+ | |
| XYZ | | |
| ABC | | |
+-------+ | |
2 rows in set (0.00 sec) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment