我有一个像
这样的查询 SELECT COUNT(ShoppingProductFeature.ShoppingFeatureId) as countShow,ShoppingProductFeature.ShoppingFeatureId as valueId, ShoppingProductFeature.ShoppingParentFeatureId as attrId, ShoppingFeatureLanguage.Title as attrName, ShoppingFeatureLanguage_1.Title AS valueName
FROM ShoppingFeatureLanguage INNER JOIN ShoppingProductFeature INNER JOIN ShoppingFeatureLanguage AS ShoppingFeatureLanguage_1 ON ShoppingProductFeature.ShoppingFeatureId = ShoppingFeatureLanguage_1.ShoppingFeatureId ON ShoppingFeatureLanguage.ShoppingFeatureId = ShoppingProductFeature.ShoppingParentFeatureId INNER JOIN ShoppingFeature ON ShoppingProductFeature.ShoppingFeatureId = ShoppingFeature.ShoppingFeatureId
INNER JOIN Product ON ShoppingProductFeature.ProductId = Product.ProductId
INNER JOIN Company ON Product.CompanyId = Company.CompanyId
GROUP BY ShoppingProductFeature.ShoppingFeatureId, ShoppingProductFeature.ShoppingParentFeatureId, ShoppingFeatureLanguage.Title, ShoppingFeatureLanguage_1.Title, ShoppingFeatureLanguage_1.LanguageId, ShoppingFeatureLanguage.LanguageId, ShoppingFeature.isConfirmed,Product.MoneyId,Product.TypeId , Company.GeoId , Product.ShoppinGroupId
HAVING (ShoppingFeatureLanguage_1.LanguageId = 2) AND (ShoppingFeatureLanguage.LanguageId = 2) AND (ShoppingFeature.isConfirmed = 1) and (Product.TypeId = 11) and Product.ShoppinGroupId like N'mn%' and Company.GeoId like N'aa%'
ORDER BY countShow DESC
很明显我必须按 countShow 对其进行排序,我必须调用COUNT(ShoppingProductFeature.ShoppingFeatureId)进行选择,因为我无法将其添加到Order By
所以结果是这样的 enter image description here
如何在没有重复数据的情况下区分数据或对其进行排序
答案 0 :(得分:0)
尝试下面的事情..
/*.jsp