mysql 连表查询返回符合要求数据条数、重复字段分组去重
程序员文章站
2022-04-12 21:33:22
...
人基础不行真的没办法,返回个条数还焊了十几分钟
SELECT COUNT(1) FROM(
SELECT
i.hotelName,
SUM(t.total_price)
FROM t_bs_hotel_info i
LEFT JOIN `t_bs_bookorder` t on i.id= t.hotelId
GROUP BY hotelName
) AS total
SELECT
i.hotelName,
SUM(t.total_price) as hotelPrice
FROM t_bs_hotel_info i
LEFT JOIN `t_bs_bookorder` t on i.id= t.hotelId
GROUP BY hotelName
ORDER BY hotelPrice DESC
上一篇: 一种新的编程思路(下):GBDP,
下一篇: dockpanel 操作方法