这是我的代码:
SELECT DATEDIFF(shippedDate, orderDate) AS '# Days', COUNT(*)
FROM datenumtest2
GROUP BY '# Days'
ORDER BY '# Days'
结果给我:
在 # 天内,有 3 个数字 5。我希望我的代码中的输出是
Days: 5 COUNT(*): 3
非常感谢任何帮助
最佳答案
在 mysql 中,你应该对列名使用反引号而不是引号
SELECT DATEDIFF(shippedDate, orderDate) AS `# Days`, COUNT(*)
FROM datenumtest2
GROUP BY `# Days`
ORDER BY `# Days`
或简单的日子
SELECT DATEDIFF(shippedDate, orderDate) AS Days, COUNT(*)
FROM datenumtest2
GROUP BY Days
ORDER BY Days
关于mysql - {MYSQL}如何获取一行,使用COUNT(*),告诉你一个数被使用了多少次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43190235/