table1
顾客 序号  价格
A    001   100
A    002   10
A    003   1
B    001   100
C    001   100table2
序号 价格 是什么东西
001  100    thing1
002  10     thing2
003  1      thing3查询返回顾客        以购物品        总价格
A     thing1,thing2,thing3   111用AdoDataSet谢谢 

解决方案 »

  1.   

    select 顾客,是什么东西 as 以购物品,sum(价格)as 总价格 from 表1,表2 where 顾客=a and table1.序号=table2.序号
      

  2.   

    select 表1.顾客,表1.是什么东西,sum(表1.价格)as 总价格 
    from 表1,表2 
    where 表1.顾客=a and 表1.序号=表2.序号
      

  3.   

    select table1.customer,table2.goodsname,(select sum(price) from table1 where customer='A')as '总价格' from table1  join table2 on
    table1.goodsid=table2.goodsid and table1.customer='A'
    group by table1.customer,table2.goodsname
    返回的记录是
    customer goodsname                      总价格                   
    -------- ------------------------------ --------------------- 
    A        白银                             111.0000
    A        黄金                             111.0000
    A        铜块                             111.0000(3 row(s) affected)
    这样行不行?
      

  4.   

    我想“白银 黄金 铜块”在同一行,用一句select可以实现吗?