2016-08-21 71 views
-1

SQL COUNT不作爲數字返回。它似乎以字符串形式返回。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 
+4

'order by' count,not the stateprovince –

+0

如果您發佈了完整的答案,我會將其標記爲正確。 – user136952

回答

0

這糾正了我的問題。

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