write sql commands to the following:-
1. display the average price of each type of vehicle having quantity more that 20.
2. count the type of vehicle manufactured by each company
3. display the total price of all the types of vehicles

plssss answerrr...​

write sql commands to the following 1 display the average price of each type of vehicle having quantity more that 202 count the type of vehicle manufactured by class=

Respuesta :

Answer:

I can't seem to add SQL to the answer, so let's try this:

For the first one, you need to build a select that uses the avg function on the price column.

For the second one, you need to use the count function.  Select that and the company, and group by company.

For the third, it's slightly unclear.  Do they mean to mean to display the total price of all vehicles or the total price of each type of vehicle.  The former would just be done by selecting a sum of the price.  The latter by selecting that and the type column, grouping by type.  I'm not sure if type is a keyword, so you might need backtick quotes wrapped around it.

See below for the SQL command of each category

How to write the SQL commands?

To do this, we make use of the following clauses:

  • SELECT
  • AVERAGE
  • WHERE
  • COUNT

Using the above highlight, we have:

Average price of each vehicle having quantity more than 20.

The table name is given as: Vehicles

To display the average, we use the following query:

SELECT

Type, avg(Price)

FROM Vehicle

GROUP BY Type

HAVING QTY >20;

Count type of vehicle by each company

To count each type of vehicle, we use the following query:

SELECT

company, COUNT(DISINCT Type)

FROM VEHICLE

GROUP BY Company;

Display the total price of all

The total price is calculated using:

Total = Price * Quantity

So, we have the following query:

SELECT

Type, SUM(Price* Qty)

FROM VEHICLE

GROUP BY Type;

Read more about SQL at:

https://brainly.com/question/25694408

#SPJ2

ACCESS MORE