129k views
5 votes
Which of the following is the valid syntax for creating a view to view a subset of a table?

A. create view album cost as select album id, sum(unit price) from track group by album id;
B. create view album cost as track group by album id;
C. create view album cost select album id, sum(unit price) from track group by album id;
C. create view album cost as select album id, sum(unit price) group by album id;

User Kajaco
by
7.5k points

1 Answer

4 votes

Final answer:

A) The valid syntax for creating a view is 'create view album_cost as select album_id, sum(unit_price) from track group by album_id;'. It creates a view named album_cost and groups the sum of unit prices by album_id.

Step-by-step explanation:

The correct syntax for creating a view to view a subset of a table in SQL is:

create view album_cost as
select album_id, sum(unit_price)
from track
group by album_id;

This statement creates a view called album_cost. It selects the album_id from the track table and calculates the sum of the unit_price for each album, grouping the results by album_id.

User Soham
by
8.0k points