sql语句处理系统空值

wab_94496491 2005-08-08 10:25:19
假如我有个字段 TimeOfDate
TimeOfDate
1984-4-5

1999-4-2

1998-6-4
TimeOfDate字段有五个记录:三个有时间,还有两个为空值(System.DBNULL.Value)
请问怎么用sql语句得到空值记录和另外两个较小的时间记录
...全文
112 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ConanKid 2005-08-08
  • 打赏
  • 举报
回复
闵峰:select * from a_date where adate is null
or id in (select top 2 id from a_date order by adate desc)
这个是取出时间较大的两个,可以改一下,从而取得较小的两个:
select * from time1 where timeofdate is null
or id in (select top 2 id from time1 where timeofdate is not null order by timeofdate)
malingxian 2005-08-08
  • 打赏
  • 举报
回复
select * from [table] where TimeOfDate is null
ConanKid 2005-08-08
  • 打赏
  • 举报
回复
如果就是这样固定的格式,是很简单的。
select top 4 *
from 表名
order by timeofdate
hamadou 2005-08-08
  • 打赏
  • 举报
回复
对于NULL值的判断方法是=还是IS,可以参看设置SET ANSI_NULLS
hamadou 2005-08-08
  • 打赏
  • 举报
回复
select * from a_date where adate is null
or id in (select top 2 id from a_date order by adate desc)
du9232 2005-08-08
  • 打赏
  • 举报
回复
where TimeOfDate is null 得到为空的记录

16,554

社区成员

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

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