gpt4 book ai didi

MySQL 查询问题

转载 作者:行者123 更新时间:2023-11-29 14:50:28 25 4
gpt4 key购买 nike

我有当前的数据库设置:

Forename | Surname | Department | Completion_Status
Tom Smith Sales Started
Bob Jones Sales Completed
Alison Baines Sales Not Started
Arthur Smith Marketing Started
Claire Staines Marketing Completed

我能够毫无问题地返回总行数,以及完成状态为“已开始”或“已完成”的总行数,但不能在单个语句中返回 - 但是我想要在单个语句中执行的是:

COUNT for Department As Total AND the COUNT for Department As Responses WHERE Completion_Status IN ('Started', 'Completed')

它看起来像这样:

Department | Total | Responses
Sales 3 2
Marketing 2 2

希望这是有道理的!?

谢谢荷马。

最佳答案

选择部门,
       COUNT(部门)              AS 总计,
       COUNT(completion_status) AS 回复
来自结果
WHERE completion_status IN ('开始', '完成')
按部门分组
按部门订购

关于MySQL 查询问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5848286/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com