1
+ Information about the table:
2
+ Table Customer:
3
+
4
+ + -- -------+------------------+-----------------------+--------+-----------+---------+----------------+
5
+ | cust_id | cname | Address | Gender | City | Pincode | TotalOrdersYet |
6
+ + -- -------+------------------+-----------------------+--------+-----------+---------+----------------+
7
+ | 546 | Rakesh Matam | Bongora, kamrup rural | M | Guwahati | 781015 | 3 |
8
+ | 1111 | Kuldeep Ravaliya | Bongora, kamrup rural | M | Guwahati | 781015 | 7 |
9
+ | 670 | Sugam Sehgal | Lajpat Nagar | M | Jalandhar | 144001 | 2 |
10
+ | 1110 | Sumit Mishra | Bongora, kamrup rural | M | Guwahati | 781015 | 1 |
11
+ | 890 | Lokesh Daga | Ashok Nagar | M | Jalandhar | 144003 | 4 |
12
+ | 700 | Riya Gupta | Dilbagh Nagar | F | Jalandhar | 144002 | 5 |
13
+ | 1251 | Ram Kumar | Dilbagh Nagar | M | Jalandhar | 144002 | 1 |
14
+ | 1300 | Shayam Singh | Ludhiana H .O | M | Ludhiana | 141001 | 15 |
15
+ | 245 | Neelabh Shukla | Ashok Nagar | M | Jalandhar | 144003 | 10 |
16
+ | 210 | Barkha Singh | Dilbagh Nagar | F | Jalandhar | 144002 | 1 |
17
+ | 500 | Rohan Arora | Ludhiana H .O | M | Ludhiana | 141001 | 7 |
18
+ + -- -------+------------------+-----------------------+--------+-----------+---------+----------------+
19
+
20
+ Problem Statement:
21
+ List down all the addresses from Jalandhar city with the number of times the address appears.
22
+ Note: Name the number of times the address appears as " Address_times" using Alias Keyword.
23
+
24
+ Solution:
25
+ SELECT address, count (address) AS Address_times FROM customer WHERE city= ' Jalandhar' GROUP BY address;
26
+
27
+ Output:
28
+ + -- -------------+---------------+
29
+ | address | Address_times |
30
+ + -- -------------+---------------+
31
+ | Lajpat Nagar | 1 |
32
+ | Ashok Nagar | 2 |
33
+ | Dilbagh Nagar | 3 |
34
+ + -- -------------+---------------+
0 commit comments