Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the e_store database Select the total amount of products in the products table. Alias the column name as total_product_count. The resulting table should look

Use the e_store database

Select the total amount of products in the products table. Alias the column name as total_product_count. The resulting table should look like this:

+---------------------+ | total_product_count | +---------------------+ | 6 | +---------------------+ 1 row in set (0.01 sec) 

Select the total stars field count of the product with id = 4. Alias the column name as stars_fields_count. The resulting table should look like this:

+----+--------------------+ | id | stars_fields_count | +----+--------------------+ | 4 | 2 | +----+--------------------+ 1 row in set (0.00 sec) 

The tables are the following

mysql> SELECT * FROM products; +----+------------+--------+-------+---------------------+ | id | name | price | stock | created_at | +----+------------+--------+-------+---------------------+ | 1 | Tablet | 145.50 | 8 | 2015-10-09 00:49:30 | | 2 | Smartphone | 90.80 | 9 | 2015-10-28 04:43:05 | | 3 | PC | 157.40 | 1 | 2015-10-10 18:13:09 | | 4 | Headphones | 20.00 | 6 | 2015-10-30 06:30:30 | | 5 | Speakers | 56.89 | 4 | 2015-10-27 12:24:56 | | 6 | Monitor | 125.45 | 7 | 2015-10-22 11:32:53 | +----+------------+--------+-------+---------------------+ 6 rows in set (0.00 sec)

mysql> SELECT * FROM reviews; +----+------------+-------+ | id | product_id | stars | +----+------------+-------+ | 1 | 6 | 5 | | 2 | 4 | 2 | | 3 | 2 | 1 | | 4 | 4 | 5 | | 5 | 1 | 5 | | 6 | 2 | 4 | | 7 | 3 | 3 | | 8 | 2 | 2 | | 9 | 1 | 3 | +----+------------+-------+ 9 rows in set (0.00 sec)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions