0

在此处输入图像描述

以上是我的查询的输出。我想按字母顺序排列排放类型,同时将地铁、阿巴拉契亚和农村TRUES组合在一起,即地铁、农村和阿巴拉契亚的所有 1 的顺序正确,但我如何按字母顺序排列第一列。以下是我的查询

SELECT     tblDischarge.dischargeType, COUNT(tblDischarge.dischargeType) AS counts, tblVisits.diabetes, tblVisits.hemiplegia, tblKentuckyCounties.Metro, 
                      tblKentuckyCounties.Appalachia, tblKentuckyCounties.Rural
FROM         tblKentuckyCounties INNER JOIN
                      tblVisits ON tblKentuckyCounties.countyID = tblVisits.countyID INNER JOIN
                      tblDischarge ON tblVisits.DischargeStatus = tblDischarge.dis_statID
WHERE     (tblVisits.diabetes = 1) AND (tblVisits.hemiplegia = 1)
GROUP BY tblDischarge.dischargeType, tblVisits.diabetes, tblVisits.hemiplegia, tblKentuckyCounties.Metro, tblKentuckyCounties.Appalachia, tblKentuckyCounties.Rural
HAVING      (tblDischarge.dischargeType LIKE '%routine%') OR
                      (tblDischarge.dischargeType LIKE '%short-term%') OR
                      (tblDischarge.dischargeType LIKE '%icf%') OR
                      (tblDischarge.dischargeType = 'home health') OR
                      (tblDischarge.dischargeType LIKE '%swing%') OR
                      (tblDischarge.dischargeType LIKE 'rehab%') OR
                      (tblDischarge.dischargeType LIKE '%long-term%')
ORDER BY tblKentuckyCounties.Appalachia, tblKentuckyCounties.Rural, tblKentuckyCounties.Metro
4

3 回答 3

2

将最后一行更改为:

ORDER BY tblKentuckyCounties.Appalachia, tblKentuckyCounties.Rural, tblKentuckyCounties.Metro, tblDischarge.dischargeType
于 2012-05-09T14:37:40.940 回答
1
ORDER BY tblKentuckyCounties.Appalachia, tblKentuckyCounties.Rural, tblKentuckyCounties.Metro, tblDischarge.dischargeType

应该这样做。

于 2012-05-09T14:43:07.303 回答
0

只需将 tblDischarge.dischargeType 添加到 ORDER BY 作为第一个值。

ORDER BY tblDischarge.dischargeType, tblKentuckyCounties.Appalachia, tblKentuckyCounties.Rural, tblKentuckyCounties.Metro

编辑

这是无法做到的,因为您正试图按照两个完全不同的标准进行排序。您只能分订单 - 每个步骤对上一步中的结果进行排序,但您只能有一个订单。

于 2012-05-09T14:38:28.960 回答