0% found this document useful (0 votes)
3 views3 pages

SQL Customer Table Queries Overview

The document outlines a series of SQL queries related to a 'customer' table, including creating the table, inserting records, and retrieving data. It shows the successful execution of various queries, such as selecting all customers, filtering by item purchased, and counting records. Additionally, it provides details on the table structure and the results of aggregate functions.

Uploaded by

raok45172
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

SQL Customer Table Queries Overview

The document outlines a series of SQL queries related to a 'customer' table, including creating the table, inserting records, and retrieving data. It shows the successful execution of various queries, such as selecting all customers, filtering by item purchased, and counting records. Additionally, it provides details on the table structure and the results of aggregate functions.

Uploaded by

raok45172
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

query1: create table customer(

id int primary key,


name varchar(20),
item_purchased varchar(20));

output: Query OK, 0 rows affected (0.02 sec)

query2: insert into customer values


(105,"hari","smart phone"),
(106,"ram","ear buds"),
(108,"keshav","back cover"),
(110,"bhavya","smart phone");

output: Query OK, 4 rows affected (0.00 sec)


Records: 4 Duplicates: 0 Warnings: 0

query3: select*from customer;

output:

+-----+--------+------------------+
| id | name | item_purchased |
+------+--------+--------------------+
| 105 | hari | smart phone |
| 106 | ram | ear buds |
| 108 | keshav | back cover |
| 110 | bhavya | smart phone |
+------+--------+--------------------+
4 rows in set (0.00 sec)

query4: select*from customer where item_purchased="smart phone";

output:
+-----+--------+------------------+
| id | name | item_purchased|
+-----+--------+------------------+
| 105 | hari | smart phone |
| 110| bhavya | smart phone |
+------+--------+------------------+
2 rows in set (0.00 sec)

query5: select min(id) from customer ;

output:
+---------+
| min(id) |
+---------+
| 105 |
+---------+
1 row in set (0.00 sec)

query6: select*from customer order by item_purchased;

output:
+----+---------+------------------+
| id | name | item_purchased |
+-----+--------+-------------------+
| 108 | keshav | back cover |
| 106 | ram | ear buds |
| 105 | hari | smart phone |
| 110 | bhavya | smart phone |
+----+---------+-------------------+
4 rows in set (0.00 sec)

query7: select name,lower(name) from customer;

output:
+----------+---------------+
| name | lower(name) |
+----------+---------------+
| hari | hari |
| ram | ram |
| keshav | keshav |
| bhavya | bhavya |
+----------+---------------+
4 rows in set (0.00 sec)

query8: select count(*) from customer;

output:
+-----------+
| count(*) |
+-----------+
| 4 |
+-----------+
1 row in set (0.00 sec)

query9: desc customer;

output:
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+--------------+-----+-----+---------+-------+
| id | int | NO | PRI | NULL |
|
| name | varchar(20) | YES | | NULL | |
| item_purchased | varchar(20) | YES | | NULL | |
+------------------+-------------+------+-----+----------+-------+
3 rows in set (0.01 sec)

query10: select count(id) from customer group by id;

output:
+------------+
| count(id) |
+------------+
| 1 |
| 1 |
| 1 |
| 1 |
+-------------+
4 rows in set (0.00 sec)

You might also like