按“品牌+月份”计算每月平均成交价(avg sale price),请写 SQL。
Calculate the average price of cars sold per brand for each month (write SQL).
题目类型: 技术面试题
这是一道技术面试题,常见于澳洲IT公司面试中。
难度: medium
分类: Carsales Interview, SQL
标签: Aggregation, DATE_TRUNC
目标公司: carsales
参考答案摘要
答案 思路:把 sold_date 截断到月份(DATE_TRUNC 或 EXTRACT),然后按 brand + month 聚合求 AVG。 参考 SQL(PostgreSQL) SELECT DATE_TRUNC('month', sold_date) AS month_of_sale, brand, AVG(sale_price) AS avg_sale_price F...
本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。