12345678910111213141516171819202122232425262728 |
- -- Active: xiaoding_test@@192.168.110.85@3306@xiaoding_test
- DROP TABLE IF EXISTS report_project_list;
- CREATE TABLE report_project_list AS
- /* 项目列表视图 */
- DROP VIEW IF EXISTS manage_project_list;
- CREATE OR REPLACE VIEW manage_project_list AS
- WITH
- order_stats AS (
- /* 统计每个项目的订单数量 */
- SELECT project_id /* 项目编号 */
- FROM `order` /* 订单表 */
- WHERE
- deleted_at IS NULL
- GROUP BY
- project_id
- )
- SELECT p.id /* 项目编号 */, p.title /* 项目名称 */, pc.name /* 项目分类名称 */, p.price /* 项目价格 */, p.duration /* 服务时长(分钟) */, p.state /* 状态 */, p.cover /* 项目封面图片 */
- FROM
- project p /* 项目表 */
- LEFT JOIN project_cate pc /* 项目分类表 */ ON p.cate_id = pc.id
- AND pc.deleted_at IS NULL
- LEFT JOIN order_stats os /* 订单统计 */ ON p.id = os.project_id
- WHERE
- p.deleted_at IS NULL
- ORDER BY p.id DESC;
|