重金 求一sql 语句 有两个表hotel(房号,价格,类型) 帐单(房号,费用,)要求说明:求帐单中房间类型为"普通"的费用总和 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select sum(帐单.房费) from 帐单 where 帐单.房号 in (select 房号 from hotel where 类型='普通')为什么这句话在sql服务器上没错误,而在vs.net运行不通? select sum([帐单]."房费") from [帐单] where [帐单]."房号" in (select "房号" from [hotel] where "类型" = '普通')如果这样也不行的话,只能南无阿弥陀佛了! select 帐单.sum(费用) from 帐单 where 帐单.房号 in(select * from hotel where 类型='普通') select sum(费用) as 费用 from 账单 join hotel on 费用.房号=hotel.房号 and hotel.类型="普通" select sum(费用) as 费用 from 账单 join hotel on 费用.房号=hotel.房号 and hotel.类型="普通" 这些sql语句都是对的,不可能有问题,注意检查一下其他的地方。 select sum(a.费用) as 费用 from 帐单 a join hotel b on a.房号=b.房号 and b.类型='普通'这句已测试了 select sum(帐单.费用) from hotel,帐单 where 帐单.房号 = hotel.房号and hotel.类型='普通' select sum(帐单.费用) as 费用 from 帐单 inner join hotel on 帐单.房号=hotel.房号wherehotel.类型='普通' 有两个表hotel(房号,价格,类型) 帐单(房号,费用,)要求说明:求帐单中房间类型为"普通"的费用总和select sum(费用) from 帐单 A,hotel B where a.房号=b.房号 and b.类型='普通' select sum(费用) from 帐单 as a ,hotel as b where a.房号=b.房号 and b.类型 like '普通' select sum(费用) from 帐单 as a left join hotel as b on a.房号=b.房号 where b.类型='普通' 调试一下 是什么问题, 如果SQL 语句正确的话, 程序调用可能就是编码的问题了。 select sum([费用]) from 帐单 where [房号] in(select * from hotel where 类型='普通') select sum([费用]) from 帐单 where [房号] in(select [房号] from hotel where 类型='普通') 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') 那應該不是sql語句的問題了,你在vs.net中出的是什麼問題呢?發出來看下了.... select sum([帐单]."房费") from [帐单] where [帐单]."房号" in (select "房号" from [hotel] where "类型" = '普通') 一般SQL没有问题是不是程序哪里的问题. select sum(费用) from 帐单 a join hotel b on a.房号 = b.房号 where b.类型 = '普通' select sum(b.费用) from hotel a left join 帐单 b on b.房号=a.房号 where a.类型='普通' winform 能否实现可以将字符输出到任意光标位置 谁有一些关于winform的小项目 隐藏托盘图标的问题!!希望得到大家的帮助谢谢 高手帮忙 !使用c#创建域帐户 开机自动启动? 一个没有思路的问题, 请教 日期格式问题。高手急救 请教如何解决:索引(从零开始)必须大于或等于零,且小于参数列表的大小。 求大神啊!!!C#出现了targetInvocationException的问题 c#操作文件时说文件正在被另一个进程使用!救命 高手帮我看看 讨论一下吧,如何清晰组织页面数据和页面方法?
这句已测试了
where 帐单.房号 = hotel.房号
and hotel.类型='普通'
from
帐单 inner join hotel on 帐单.房号=hotel.房号
where
hotel.类型='普通'
帐单(房号,费用,)要求说明:求帐单中房间类型为"普通"的费用总和select sum(费用) from 帐单 A,hotel B where a.房号=b.房号 and b.类型='普通'
left join hotel as b on a.房号=b.房号
where b.类型='普通'
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')
發出來看下了....