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

Midterm Laboratory Exam (100 Points)

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)
18 views3 pages

Midterm Laboratory Exam (100 Points)

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

MIDTERM LABORATORY EXAM (100 points)

Create a Database name storedb


Create two tables: “employees” and “products”
creating database, tables with structure and syntaxes

Statement analysis:
1. Use the SQL SELECT statement with the combination of COUNT(*), SUM, and GROUP BY in
employees table only.
The output must be this one:
1.)

2. Use the SQL SELECT statement with the combination of COUNT(*), SUM, AVG in employees table
only.
The output must be this one:
2.

3. Use LIKE Conditional Operators to search a name with start with letter “J” in employees table.
The output must be this one:
3.
CREATE DATABASE storedb

Table structure for table `employees`


CREATE TABLE `employees` (
`id` int(5) NOT NULL,
`name` varchar(100) DEFAULT NULL,
`address` varchar(100) DEFAULT NULL,
`mobile` int(25) DEFAULT NULL,
`deptid` int(2) NOT NULL,
`mgr` int(5) DEFAULT NULL,
`salary` double DEFAULT NULL,
`comm` double DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

Insert data for table `employees`


INSERT INTO `employees` (`id`, `name`, `address`, `mobile`, `deptid`,
`mgr`, `salary`, `comm`) VALUES
(1, 'kyla', 'binalonan', 91235525, 1, NULL, 10000, NULL),
(2, 'daniel', 'tayug', 95088667, 1, 1, 11000, NULL),
(3, 'jhelly', 'dagupan', 936362225, 2, 1, 13400, NULL),
(4, 'renz', 'sta. barbara', 94535323, 3, 2, 15000, 2000),
(5, 'Jenny', 'Calasiao', 94523259, 1, 2, 90000, NULL),
(6, 'vivian', 'mangaldan', 93636228, 1, 2, 8500, NULL);

ALTER TABLE `employees`


ADD PRIMARY KEY (`id`);
-- AUTO_INCREMENT for dumped tables
--
-- AUTO_INCREMENT for table `employees`
ALTER TABLE `employees`
MODIFY `id` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
COMMIT;

Table structure for table `products`


CREATE TABLE `products` (
`id` int(11) NOT NULL,
`description` varchar(150) DEFAULT NULL,
`price` double DEFAULT NULL,
`qty` int(4) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

Insert data for table `products`


INSERT INTO `products` (`id`, `description`, `price`, `qty`) VALUES
(1, 'refrigerator', 15000, 5),
(2, 'ricecooker', 5000, 10),
(3, 'electric fan', 3000, 20),
(4, 'blender', 6000, 10),
(5, 'oven', 30000, 10);

-- Indexes for table `products`

ALTER TABLE `products`


ADD PRIMARY KEY (`id`);

-- AUTO_INCREMENT for dumped tables

-- AUTO_INCREMENT for table `products`

ALTER TABLE `products`


MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
COMMIT;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy