劳驾 这个sql查询怎么写

[复制链接]
查看11 | 回复2 | 2010-4-10 19:08:52 | 显示全部楼层 |阅读模式
select f_id,sum(f_price),t_name from 类型,消费 where 类型.t_id=消费.t_id group by 类型.t_id
回复

使用道具 举报

千问 | 2010-4-10 19:08:52 | 显示全部楼层
selectt_type.t_Name,sum(t_cost.f_Price)from t_type,t_costwhere t_type.t_Id = t_cost.t_Idgroup by t_type.t_Name其中t_type 类型表
t_cost 消费表你要的结果f_Id f_Price t_Id1
22.00 12
20.00 23
30.00 3f_Id 这个是消费表里的字段吗?如果是的话 那类型C怎么会对应 f_Id= 3呢?
回复

使用道具 举报

千问 | 2010-4-10 19:08:52 | 显示全部楼层
SELECTSUM(CONVERT(float, 消费表.price)) AS f_price, 类型表.t_NameFROM 消费表 INNER JOIN 类型表 ON 类型表.id = 消费表.idGROUP BY类型表.namef_id不能搜出来,如果显示在网页上可以做出来!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行