Generated on Jan 15, 2025, 11:15:20 AMgemini-1.5-flash
-- Common Table Expression (CTE) to calculate the average list price of products.
WITH AvgPrice AS (
SELECT
AVG(list_price) AS average_price -- Calculate the average of the list_price column.
FROM
BikeStores..products -- Specify the table to retrieve data from.
)
-- Select the formatted average price and the count of products priced above average.
SELECT
FORMAT(average_price, 'C', 'en-GB') AS "Average Price", -- Format the average price using the currency format for Great Britain.
(SELECT COUNT(*) FROM BikeStores..products WHERE list_price > average_price) AS "Products Priced Above Average" -- Subquery to count products with list price exceeding the average.
FROM
AvgPrice; -- Select from the CTE to access the calculated average price.