在同一列上选择两个计数
我有两个选择查询:
SELECT MONTH(date) AS month, count(DISTINCT ip)
FROM table_name WHERE field = 1 GROUP BY month
如何
SELECT MONTH(date) AS month, count(DISTINCT ip)
FROM table_name WHERE field = 2 GROUP BY month
编写一个查询来选择
SELECT MONTH(date) AS month,
count(DISTINCT ip) [ for field = 1],
count(DISTINCT ip) [ for field = 2]
I have two select queries:
SELECT MONTH(date) AS month, count(DISTINCT ip)
FROM table_name WHERE field = 1 GROUP BY month
and
SELECT MONTH(date) AS month, count(DISTINCT ip)
FROM table_name WHERE field = 2 GROUP BY month
how can I write one query to select
SELECT MONTH(date) AS month,
count(DISTINCT ip) [ for field = 1],
count(DISTINCT ip) [ for field = 2]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)