access 为空字段 替换,Access 2010-需要用值替换空值

I have a query that looks at two times and calculates the difference and puts the value (in seconds) in another field. I then sort that field. The problem is when one of the times is empty the row in the new field in not populated so when I do the sort the rows that nothing in them are pushed to the top.

What I would like to do is replace the null with another value. Something like 9999999. That way when I perform the sort the rows that now have 999999 will be place at the bottom of the sort.

Here is the SQL Expression for the query.

SELECT FOCFClassic.FirstName, FOCFClassic.LastName, FOCFClassic.[Bib#], FOCFClassic.[2011SDStartTime], FOCFClassic.[2011SDFinishTime], Diff2Dates("ns",[FOCFClassic].[2011SDStartTime],[FOCFClassic].[2011SDFinishTime]) AS 2011SDRunTime, FOCFClassic.SDCategory, FOCFClassic.Team, FOCFClassic.SDRank, DateDiff("s",[2011SDStartTime],[2011SDFinishTime]) AS TotalTime

FROM FOCFClassic

WHERE (((Diff2Dates("ns",[FOCFClassic].[2011SDStartTime],[FOCFClassic].[2011SDFinishTime]))<>"") AND ((DateDiff("s",[2011SDStartTime],[2011SDFinishTime])) Is Not Null))

ORDER BY FOCFClassic.SDRank, DateDiff("s",[2011SDStartTime],[2011SDFinishTime]);

I'm a noob at this so a little hand holding my be needed.

Thanks is advance!

Gordon

解决方案

You can either use the NZ() function: NZ(MyDate, #1/1/1950#) will return jan 1st 1950 if the field is null, the field value otherwise. You can achieve the same result using IIF() and ISNULL() functions or IS NULL condition.

In terms of performance, using IIF(myDate IS NULL, #1/1/1950#, myDate) should be the fastest.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值