当前位置: 代码迷 >> Oracle开发 >> 求一条SQL,多谢大侠们
  详细解决方案

求一条SQL,多谢大侠们

热度:32   发布时间:2016-04-24 07:30:09.0
求一条SQL,谢谢大侠们!
表A(消费记录) 字段有:id(主键),money(金额),recordDate(记录时间),bid(主B表关联ID)
表B(人员信息)字段有:id(主键),name(姓名),age(年龄),

A表中的信息是每一次的消费记录,B表中是每个人的基本信息

现在想用SQL 查出每个人的消费总数, 查出:B.name ,B.age ,sum(A.money) ,查询条件为 where B.name like '%%'



------解决方案--------------------
SQL code
select b.name,b.age,sum(a.money) as totalfrom a inner join b on a.bid=b.idwhere b.name like '%%'group by b.name,b.age
  相关解决方案