英文:
Why does ORDER BY command not print value in ascending order as it is by default in ascending?
问题
我正在学习SQL,并且正在使用Microsoft SQL Server Management Studio 19。我是从YouTube学习的,视频中说ORDER BY
默认按升序设置内容。
但在我的机器上情况正好相反,我还尝试过使用ASC和DESC调用。
我希望数据按升序排列,即先是计数2,然后是计数3。
英文:
I am on a learning phase of SQL and I'm using the Microsoft SQL Server Management Studio 19. I was learning from Youtube, where the video states that the ORDER BY
call by default sets the contents in ascending order.
But in my machine it is the other way around I also tried using the ASC and DESC calls.
I wanted the data to be arranged in ascending order i.e., count 2 and then count 3
答案1
得分: 2
在这种情况下,你需要按计数而不是按性别排序。
...
ORDER BY COUNT(Gender) ASC;
英文:
In that case you need to order by the count and not the gender.
...
ORDER BY COUNT(Gender) ASC;
答案2
得分: 0
'AgeCount'一词在实际上是性别统计(或30岁以上的性别统计)时,可能会令人困惑,无论是对您自己还是其他人。
英文:
Another side note: calling the result column 'AgeCount' when it's actually a gender count (or gender-count-over-30, anyway) could be confusing, for yourself as well as others.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论