Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem setting up query
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01320274
Message ID:
01320287
Views:
17
>I am having problem getting foxpro to accurately represent a query for one of my databases. This query pulls from two different tables, with the id being conclusive to both tables. I want this query to not include records that have no report names. However, when I include "AND reports.rptname != NULL" or "AND reports.rptname != "", the query turns up empty. When I run it without those, I get several hundred records, with about 75 or so records having a blank rptname. Any thoughts on this? I'm pretty baffled by the inclusion of either of those case statements wiping out all records that show up in the query. Thanks for any advice.
>
>
>SELECT DISTINCT Sitedata.id, Sitedata.site_name, Sitedata.r1,;
>  Sitedata.city, Sitedata.status,;
>  reports.recvdate, reports.respdate, reports.rptname;
> FROM ;
>     events!Sitedata;
> LEFT OUTER JOIN events!reports ;
>   ON  sitedata.id = reports.id;
> WHERE reports.respdate = {};
> 		AND reports.rptname != NULL; *Should make sure there is a report listed
> 		AND (Sitedata.status = "O" OR Sitedata.status = "M"); *Indicates the case is open or monitoring
> 		AND DATE() > reports.recvdate + 30 ; *Indicates it has been more than 30 days since the received date
> 		AND reports.recvdate = (select max (recvdate) from Reports where SiteData.ID = Reports.ID) ; *grabs only the last report
> 		AND reports.recvdate != {}; *Makes sure there is a received date
> ORDER BY Sitedata.id;
> INTO CURSOR reviewer
>WITH thisform
>.WindowState = 2
>ENDWITH	
>BROWSE
>thisform.Visible = .F.
>WITH thisform
>.WindowState = 0
>ENDWITH	
>DO FORM frmexport.scx TO m.exportcheck
>IF m.exportcheck = "a"
>	EXPORT TO C:\Temp\NoReviewer.xls TYPE xls 	
>ENDIF
>thisform.Visible = .T.
>
I forgot. You can't compare NULLs like any other values.
Treat NULL as "I don't know", It is hard to say if something equal or not to "I don't now".
Even "I don't now" can't be equal or different than "I don't now" :-)
To compare NULL you could use something like this:
? NVL(reports.rptname,'') == ''
Or in SQL Statements you could use IS NULL (Like Sergey)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform