In Delphi XE5, I use TADODataSet and set its CommandText to this command (with CASE ) :
SELECT Master.*, CASE ( SELECT TOP (1) personeli_State FROM Detail WHERE Detail.FK_Key = Master.pk_key AND Detail.personeli_State = 'Test' AND Detail.sended = 0 ) WHEN 'Test' THEN 'Test exist' ELSE '' END AS PersonState FROM Master LEFT OUTER JOIN ExtraInfo ON ExtraInfo.p_key = Master.fk_ExtraInfo WHERE (fk_key=:Fk)
And the record set is empty, but without CASE contains a list of record records. (I cannot use a computed column or SQL Server view because I have a dynamic query)
source share