Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 NEWBIE: SQL Query/VBScript Question

Author  Topic 

kwilliams

194 Posts

Posted - 2004-03-16 : 11:29:55
Hello,

Thanks for any help in advance.
BRIEF VERSION OF QUESTION:
I have 2 Views that pull Employment data: Employment_App_VIEW (EA), and Employ_Jobs_VIEW (EJ). The problem lies in the operator in the second WHERE Clause (EA.Application_Date <> 'NULL'). When I try to change the <> operator to the = operator to get the opposite results, no results show up. This is what I came up with for the first query (that works):
SELECT     *
FROM Employment_App_VIEW EA INNER JOIN
Employ_Jobs_VIEW EJ ON EA.App_ID = EJ.App_ID
WHERE (EJ.Creation_Date LIKE '03%') AND (EA.Application_Date <> 'NULL')
ORDER BY EA.Application_Date DESC]


So I ofcourse thought that all I'd have to do to pull users with "<NULL>" values in their "Application_Date" column was to do this query:

SELECT     *
FROM Employment_App_VIEW EA INNER JOIN
Employ_Jobs_VIEW EJ ON EA.App_ID = EJ.App_ID
WHERE (EJ.Creation_Date LIKE '03%') AND (EA.Application_Date = 'NULL')
ORDER BY EA.Application_Date DESC]


...but the "AND (EA.Application_Date = 'NULL')" line doesn't seem to work. Shouldn't the = operator work in the opposite way of the <> operator? And since the <> operator query works, why wouldn't the query that uses the = operator instead?

DETAILED VERSION OF QUESTION:
I'm working on creating a job that will pulls users from 2 Views I created that have added one or more jobs to their application today using the "Application Date" column from Employment_App_VIEW (EA), and another report of who has actually submitted their application today using the "Creation_Date" column from Employ_Jobs_VIEW (EJ). (See queries above for problem)

KWilliams

raymondpeacock
Constraint Violating Yak Guru

367 Posts

Posted - 2004-03-16 : 11:34:29
Use the IS NULL comparison as you can't use = 'NULL'.

.. AND (EA.ApplicationDate IS NULL)


Raymond
Go to Top of Page

kwilliams

194 Posts

Posted - 2004-03-16 : 12:08:35
Wow, thanks for the siple solution Raymond. It worked great. It's difficult being a NEWBIE, but that's how we learn. Thanks again.

KWilliams
Go to Top of Page

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2004-03-16 : 12:36:40
I think this needs to be changed too.

WHERE (EJ.Creation_Date LIKE '03%') AND (EA.Application_Date <> 'NULL')

to

WHERE (EJ.Creation_Date LIKE '03%') AND (EA.Application_Date IS NOT NULL)

Go to Top of Page
   

- Advertisement -