SQL COUNT未作为数字返回。它似乎以字符串形式返回

时间:2016-08-21 03:31:51

标签: sql sorting casting

SQL COUNT未以数字形式返回。它似乎以字符串形式返回。

SELECT 
    Count (StateProvince)
FROM 
    CUSTOMER
JOIN 
    INVOICE ON CustomerID = FK_CustomerID
GROUP BY 
    StateProvince
ORDER BY 
    StateProvince DESC

然后我的结果是

2
1
10
1
1

我认为group by正在返回一个字符串?无论哪种方式,我如何得到结果

10
2
1
1
1

1 个答案:

答案 0 :(得分:0)

这纠正了我的问题。

SELECT Count (StateProvince) AS "Count"
FROM CUSTOMER
  JOIN INVOICE
    ON CustomerID = FK_CustomerID
GROUP BY StateProvince
ORDER BY Count DESC