my sql file
my sql file
Sql Query:-
show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| xyz_company |
+--------------------+
5 rows in set (0.00 sec)
# Create Database
mysql> create database taniya;
Query OK, 1 row affected (0.16 sec)
Sql Query:-
# Adding data with insert
mysql> create table product1(product_code int, product_name varchar(30),
product_price int);
Query OK, 0 rows affected (0.08 sec)
Sql Query:-
#AVG
mysql> select avg(product_price) as product_price from product1;
+---------------+
| product_price |
+---------------+
| 616.6667 |
+---------------+
1 row in set (0.09 sec)
#COUNT
mysql> select count(*) as total_product from product1;
+---------------+
| total_product |
+---------------+
| 3|
+---------------+
1 row in set (0.07 sec)
#MAX
mysql> select max(product_price) as maximum from product1;
+---------+
| maximum |
+---------+
| 950 |
+---------+
1 row in set (0.06 sec)
#MIN
mysql> select min(product_price) as minimum from product1;
+---------+
| minimum |
+---------+
| 400 |
+---------+
1 row in set (0.04 sec)
# GROUP BY
mysql> select product_code, sum(product_price) as product_total from
product1
-> group by product_code;
+--------------+---------------+
| product_code | product_total |
+--------------+---------------+
| 101 | 500 |
| 103 | 400 |
| 104 | 950 |
+--------------+---------------+
3 rows in set (0.05 sec)
#HAVING
mysql> select product_code, sum(product_price) as product_total from
product1
-> group by product_code
-> having sum(product_price)>=450
-> order by product_total desc;
+--------------+---------------+
| product_code | product_total |
+--------------+---------------+
| 104 | 950 |
| 101 | 500 |
+--------------+---------------+
2 rows in set (0.05 sec)