# Write a query to display a brand name and the number of products of that brand that are in the database. Sort the output by the brand name.

### Database Systems: Design, Implemen...

12th Edition
Carlos Coronel + 1 other
Publisher: Cengage Learning
ISBN: 9781305627482

Chapter
Section

### Database Systems: Design, Implemen...

12th Edition
Carlos Coronel + 1 other
Publisher: Cengage Learning
ISBN: 9781305627482
Chapter 7, Problem 51P
Textbook Problem
5 views

## Write a query to display a brand name and the number of products of that brand that are in the database. Sort the output by the brand name.

Program Plan Intro

SELECT statement: It is used to retrieve information from the table or database. The syntax for the “SELECT” statement is given below:

SELECT * FROM table_Name;

WHERE clause: “WHERE” statement is used limit the number of rows.

For example: Consider a table “FTable” that has two columns named “FruitName” and “Color”. “WHERE” clause is used when there is a need to display the entire FruitName whose color is Red.

SELECT * FROM FTable WHERE color = 'red';

When the above statement is executed, red colored fruits get displayed.

“COUNT()” function: In SQL, the “COUNT()” function will return the total number of rows in the table with satisfying the criteria mentioned in the “WHERE” clause.

GROUP BY Clause: The GROUPBY clause is used to group the result of a SELECT statement done on a table where the tuple values are similar for more than one column

Syntax:

SELECT expression1, expression2, expression_n, aggregate_function(expression)FROM table_name WHERE conditions GROUP BY expression1, expression2, expression_n;

ORDER BY Clause:

SQL contains “ORDER BY” clause in order to sort rows. The values get sorted in ascending as well as descending order. The keyword used to sort values in ascending order is “ASC” and for descending order is “DESC”. By default, it sorts values by ascending order.

Syntax:

SELECT column_Name1, column_Name2 FROM table_Name ORDER BY column_Name2;

### Explanation of Solution

SQL code:

The SQL code to find the number of products of each brand is given below:

SELECT BRAND_NAME, Count(PROD_SKU) AS NUMPRODUCTS FROM LGBRAND AS B, LGPRODUCT AS P WHERE B.BRAND_ID = P.BRAND_ID GROUP BY BRAND_NAME ORDER BY BRAND_NAME;

Explanation:

• The above query will display the employees’ “BRAND_NAME” and then ...

### Still sussing out bartleby?

Check out a sample textbook solution.

See a sample solution

#### The Solution to Your Study Problems

Bartleby provides explanations to thousands of textbook problems written by our experts, many with advanced degrees!

Get Started

Find more solutions based on key concepts
What is the difference between a cybercriminal and a cyberterrorist?

Principles of Information Systems (MindTap Course List)

The deflection of a cantilevered beam supporting the weight of an advertising sign is given by y=Wx26EI(3Lx) wh...

Engineering Fundamentals: An Introduction to Engineering (MindTap Course List)

What percentage of ethanol does E85 contain?

Automotive Technology: A Systems Approach (MindTap Course List)

If your motherboard supports ECC DDR3 memory, can you substitute non-ECC DDR3 memory?

A+ Guide to Hardware (Standalone Book) (MindTap Course List)

Problems Exchanging Files You are attempting to use Bluetooth to send files from your phone to your computer. W...

Enhanced Discovering Computers 2017 (Shelly Cashman Series) (MindTap Course List)

What type of welding uses a hammer to join heated and softened metal?

Welding: Principles and Applications (MindTap Course List)