Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why this SQL Select does not work?
Message
From
11/03/2022 14:50:09
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01683823
Message ID:
01683826
Views:
31
>>>Hi,
>>>
>>>I have been struggling with the following issue.
>>>
>>>I will start with the SQL Select that works:
>>>
>>>select * from work_his join eq_file on eq_file.id_number = work_his.id_number and eq_file.site_no = 8 
>>>
>>>
>>>The above selects records from the table WORK_HIS. No problem.
>>>
>>>Now I want to add a WHERE so that only more recent records are selected. Here is the SQL Select:
>>>
>>>select * from work_his join eq_file on eq_file.id_number = work_his.id_number and eq_file.site_no = 8 
>>>where cast(DATE_CLOS as date) = ( Select MAX( cast(DATE_CLOS as date)) from work_his)
>>>
>>>
>>>That is, I added the WHERE to the above SQL Select. Now No records are selected.
>>>
>>>What am I missing?
>>>
>>>TIA
>>
>>Maybe ALL Date_Clos field are NULLs?
>
>I checked. There are not. But I will double check.

Aside boring *, try to alias your cursors, as usual
select * from work_his AS Cur1 join eq_file  AS Cur2 on Cur2.id_number = Cur1.id_number and Cur2.site_no = 8 
where cast(Cur1.DATE_CLOS as date) = ( Select MAX( cast(Cur3.DATE_CLOS as date)) from work_his AS Cur3)
else it is not clear where the field belongs.

Also, please care to mention if this is VFP SQL or?
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform