SQL Server Why does ORDER BY command not print value in ascending order as it is by default in ascending?

r7knjye2  于 2023-05-16  发布在  其他
关注(0)|答案(2)|浏览(164)

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

fcipmucu

fcipmucu1#

In that case you need to order by the count and not the gender.

...
ORDER BY COUNT(Gender) ASC;
bvuwiixz

bvuwiixz2#

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.

相关问题