ORDER BY命令为什么默认情况下不按升序打印值?

huangapple go评论62阅读模式
英文:

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调用。

ORDER BY命令为什么默认情况下不按升序打印值?

我希望数据按升序排列,即先是计数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.

ORDER BY命令为什么默认情况下不按升序打印值?

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.

huangapple
  • 本文由 发表于 2023年5月7日 22:48:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76194625.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定