这个sql语句怎么转换成Hql语句
SELECTdistinctmerchant_areaasname,(selectcount(*)frommerchantwheremerchant_area=name)...
SELECT distinct merchant_area as name,(select count(*) from merchant where merchant_area=name) as num
FROM merchant; 展开
FROM merchant; 展开
1个回答
展开全部
首先,我要给你提点建议,你这个查询不用那么麻烦的,sql不是有group by吗,用那个即可
SELECT merchant_area as name,count(*) as num
FROM merchant
GROUP BY merchant_area
改成HQL为
SELECT m.merchantArea AS name,COUNT(m.ID) AS num FROM Merchant AS m GROUP BY m.merchantArea
SELECT merchant_area as name,count(*) as num
FROM merchant
GROUP BY merchant_area
改成HQL为
SELECT m.merchantArea AS name,COUNT(m.ID) AS num FROM Merchant AS m GROUP BY m.merchantArea
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询