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

Mysql Stock 12 A

Uploaded by

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

Mysql Stock 12 A

Uploaded by

aka711964
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

mysql> use 12a2024;

Database changed

mysql> create table stock(item_no int, item_name varchar(20), dcode int, quantity int, price int,
stock_date date);

Query OK, 0 rows affected (0.03 sec)

mysql> insert into stock values(5005, 'ball pen classic', 102, 100, 26, '2020-03-31');

Query OK, 1 row affected (0.01 sec)

mysql> select* from stock;

+---------+------------------+-------+----------+-------+------------+

| item_no | item_name | dcode | quantity | price | stock_date |

+---------+------------------+-------+----------+-------+------------+

| 5005 | ball pen classic | 102 | 100 | 26 | 2020-03-31 |

| 5003 | ball pen | 102 | 150 | 30 | 2020-01-01 |

| 5002 | gel pen | 101 | 125 | 24 | 2022-02-14 |

| 5006 | gel pen classic | 101 | 200 | 32 | 2021-01-10 |

| 5001 | eraser small | 102 | 210 | 18 | 2023-03-14 |

| 5004 | eraser big | 102 | 60 | 22 | 2020-12-12 |

| 5009 | sharpner classic | 103 | 160 | 20 | 2023-01-23 |

+---------+------------------+-------+----------+-------+------------+

7 rows in set (0.00 sec)

mysql> select item_no, item_name, price from stock order by stock_date;

+---------+------------------+-------+

| item_no | item_name | price |

+---------+------------------+-------+

| 5003 | ball pen | 30 |

| 5005 | ball pen classic | 26 |

| 5004 | eraser big | 22 |


| 5006 | gel pen classic | 32 |

| 5002 | gel pen | 24 |

| 5009 | sharpner classic | 20 |

| 5001 | eraser small | 18 |

+---------+------------------+-------+

7 rows in set (0.00 sec)

mysql> select max(price), min(price) from stock;

+------------+------------+

| max(price) | min(price) |

+------------+------------+

| 32 | 18 |

+------------+------------+

1 row in set (0.01 sec)

mysql> select sum(price) from stock;

+------------+

| sum(price) |

+------------+

| 172 |

+------------+

1 row in set (0.00 sec)

mysql> select count(*) from stock;

+----------+

| count(*) |

+----------+

| 7|

+----------+

1 row in set (0.00 sec)


mysql> select avg(quantity) from stock where item_name like 'G%' or item_name like 'B%';

+---------------+

| avg(quantity) |

+---------------+

| 143.7500 |

+---------------+

1 row in set (0.01 sec)

mysql> select count(*) from stock where price<25;

+----------+

| count(*) |

+----------+

| 4|

+----------+

1 row in set (0.00 sec)

mysql> select item_name, quantity, stock_date from stock where quantity>100 and
stock_date<'2021-12-30';

+-----------------+----------+------------+

| item_name | quantity | stock_date |

+-----------------+----------+------------+

| ball pen | 150 | 2020-01-01 |

| gel pen classic | 200 | 2021-01-10 |

+-----------------+----------+------------+

2 rows in set (0.00 sec)

You might also like