有两个表hotel(房号,价格,类型)
         帐单(房号,费用,)要求说明:求帐单中房间类型为"普通"的费用总和

解决方案 »

  1.   

    select sum(帐单.房费) from 帐单 where 帐单.房号 in (select 房号 from hotel where 类型='普通')为什么这句话在sql服务器上没错误,而在vs.net运行不通?
      

  2.   

    select sum([帐单]."房费") from [帐单] where [帐单]."房号" in (select "房号" from [hotel] where "类型" = '普通')如果这样也不行的话,只能南无阿弥陀佛了!
      

  3.   

    select 帐单.sum(费用) from 帐单 where 帐单.房号 in(select * from hotel where 类型='普通')
      

  4.   

    select sum(费用) as 费用 from 账单 join hotel on 费用.房号=hotel.房号 and hotel.类型="普通"
      

  5.   

    select sum(费用) as 费用 from 账单 join hotel on 费用.房号=hotel.房号 and hotel.类型="普通"
      

  6.   

    这些sql语句都是对的,不可能有问题,注意检查一下其他的地方。
      

  7.   

    select sum(a.费用) as 费用 from 帐单 a join hotel b on a.房号=b.房号 and b.类型='普通'
    这句已测试了
      

  8.   

    select sum(帐单.费用) from hotel,帐单 
    where 帐单.房号 = hotel.房号
    and hotel.类型='普通'
      

  9.   

    select sum(帐单.费用) as 费用 
    from 
    帐单 inner join hotel on 帐单.房号=hotel.房号
    where
    hotel.类型='普通'
      

  10.   

    有两个表hotel(房号,价格,类型)
             帐单(房号,费用,)要求说明:求帐单中房间类型为"普通"的费用总和select sum(费用) from 帐单 A,hotel  B where a.房号=b.房号 and b.类型='普通'
      

  11.   

    select sum(费用) from 帐单 as a ,hotel as b where a.房号=b.房号 and b.类型 like '普通'
      

  12.   

    select sum(费用) from 帐单 as a 
    left join hotel as b on a.房号=b.房号 
    where b.类型='普通'
      

  13.   

    调试一下 是什么问题, 如果SQL 语句正确的话, 程序调用可能就是编码的问题了。
      

  14.   

    select sum([费用]) from 帐单 where [房号] in(select * from hotel where 类型='普通')
      

  15.   

    select sum([费用]) from 帐单 where [房号] in(select [房号] from hotel where 类型='普通')
      

  16.   

    create table #tmp_hotel(
    door_no char(10),
    charge char(10),
    door_type char(10)
    )
    create table #tmp_tab(
    door_no char(10),
    ttl_char char(10)
    )
    insert into #tmp_hotel values ('001','120.00','normal')
    insert into #tmp_hotel values ('002','200.00','larger')
    insert into #tmp_hotel values ('003','110.00','normal')
    insert into #tmp_hotel values ('004','130.00','normal')
    insert into #tmp_tab values ('001','120.00')
    insert into #tmp_tab values ('002','200.00')
    insert into #tmp_tab values ('003','110.00')
    insert into #tmp_tab values ('004','130.00')
    select sum(convert(numeric(10,0),[帐单].[费用ttl_char])) from #tmp_tab[帐单] where [帐单].[房号door_no] in ( select [hotel].[房号door_no] from #tmp_hotel[hotel] where [hotel].[类型door_type] = 'normal')
      

  17.   

    那應該不是sql語句的問題了,你在vs.net中出的是什麼問題呢?
    發出來看下了....
      

  18.   

    select sum([帐单]."房费") from [帐单] where [帐单]."房号" in (select "房号" from [hotel] where "类型" = '普通')
      

  19.   

    一般SQL没有问题是不是程序哪里的问题.
      

  20.   

    select sum(费用) from 帐单 a join hotel b on a.房号 = b.房号 where b.类型 = '普通'
      

  21.   

    select  sum(b.费用) from hotel a left join 帐单 b on b.房号=a.房号 where a.类型='普通'