sql语句求助

li98350 2003-08-24 11:03:02
OleDbDataAdapter1.SelectCommand.CommandText = "select '" & zm(i) & "' as 发站,'" & zm(j) & "' as 到站,sum(rs) as 人数 from rs where year(rq)='" & Year(TextBox1.Text) & "' and month(rq)='" & Month(TextBox1.Text) & "' and cc=" & dqcc & " and fz='" & zm(i) & "' And dz ='" & zm(j) & "'"
返回的结果有很多sum(rs)为null的,想去掉,在sql的where子句里怎么实现?
...全文
55 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
hiyejpgd 2003-08-24
  • 打赏
  • 举报
回复
OleDbDataAdapter1.SelectCommand.CommandText = " select * from ( select '" & zm(i) & "' as 发站,'" & zm(j) & "' as 到站,sum(rs) as 人数 from rs where year(rq)='" & Year(TextBox1.Text) & "' and month(rq)='" & Month(TextBox1.Text) & "' and cc=" & dqcc & " and fz='" & zm(i) & "' And dz ='" & zm(j) & "') a where not a.人數 is null"
Brunhild 2003-08-24
  • 打赏
  • 举报
回复
这是我对一个ACCESS数据库的查询,看对你有没有用:

select 产品名称, sum(数量) as total from 新品输入 group by 产品名称 having not isnull(sum(数量))
li98350 2003-08-24
  • 打赏
  • 举报
回复
第一位大哥 hiyejpgd(叶金平在广东) 的回复完全正确,谢谢大哥,区区20分不成敬意!
canyqf 2003-08-24
  • 打赏
  • 举报
回复
OleDbDataAdapter1.SelectCommand.CommandText = "select '" & zm(i) & "' as 发站,'" & zm(j) & "' as 到站,sum(rs) as 人数 from rs where year(rq)='" & Year(TextBox1.Text) & "' and month(rq)='" & Month(TextBox1.Text) & "' and cc=" & dqcc & " and fz='" & zm(i) & "' And dz ='" & zm(j) & "' AND rs NOT IS NULL"
neodotnet 2003-08-24
  • 打赏
  • 举报
回复
WHERE rs <> 0

将rs字段默认值设为0

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧