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:
01320284
Views:
13
Could it be that there are records just without a Report name in the Reports file?

>>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 don't get it. when you have this:
>reports.rptname != NULL,
>why you use LEFT JOIN? If you need only these records that are in BOTH tables use INNER JOIN.
>
>SELECT DISTINCT Sitedata.id, Sitedata.site_name, Sitedata.r1,;
>                Sitedata.city, Sitedata.status,;
>                reports.recvdate,;
>                reports.respdate,;
>                reports.rptname;
>FROM events!Sitedata;
>INNER JOIN events!reports ON  sitedata.id = reports.id;
>WHERE reports.respdate = {};
>      AND (Sitedata.status = "O" OR Sitedata.status = "M")                                       ; &&Indicates the case is open or monitoring
>      AND reports.recvdate < (DATE() - 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
>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform