Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Expression: IsNull Function

Status
Not open for further replies.

ThaoVy

MIS
Apr 2, 2007
16
US
Hello,

Below is my SQL Expression:
(SELECT Sum ("tblProjectBusinessTypes"."Cost")
FROM tblProjectBusinessTypes
WHERE "tblProjectBusinessTypes"."ProjectNum" = "tblProjects"."ProjectNum")

However, I only want to pull those with no CompDate and no Cancelled Date.

CompDate: If IsNull ({tblProjectBusinessTypes.CompletedDate}) Then
{tblProjects.ProjectCompletedDate} Else
{tblProjectBusinessTypes.CompletedDate}

Cancelled Date: If IsNull ({tblProjectBusinessTypes.ClosedNoBidDate}) Then
{tblProjects.ClosedNoBidDate} Else
{tblProjectBusinessTypes.ClosedNoBidDate}

How can I accomplish this in an SQL Expression. Thanks so much in advance for your help.




 
you seem to have another table in your if statements. you will first need to join those tables together.
I have called them a and b to make it easier to read
tblprojects = a
tblprojectbusinesstypes = b

you will need to put this in your select statement

(case when b.CompletedDate is null then a.ProjectCompletedDate
else b.CompletedDate end) as compDate,

(case when b.ClosedNoBidDate is null then a.ClosedNoBidDate
else b.ClosedNoBidDate end) as Cancelled_date



 
Post your software version, and why you care whether it's in a SQL Expression.

Recent versions might use a Command Object akin to:

SELECT Sum ("tblProjectBusinessTypes"."Cost")
FROM tblProjectBusinessTypes
WHERE "tblProjectBusinessTypes"."ProjectNum" = "tblProjects"."ProjectNum")
and
CompDate is null
and
CancelledDate is null

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top