Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Why doesn't this SQL work
Sat, Jan 4 2020 12:30 PMPermanent Link

Greg Hallam

Microcalm Solutions Inc

Doesn't work:

Select O.*,
   (Select Message From (SELECT Message, type, Modtime FROM EventLog Where EventID = O.ID) X
       WHERE Type = 'BOLcn' Order by ModTime Desc RANGE 1 TO 1) CarrierName
 From Orders O
Order By O.Date Desc, O.OrderNumber

ElevateDB Error #700 An error was found in the statement at line 2 and column 87 (Expected column name expression but instead found "O"."ID")


Does work:

Select O.*,
   (Select E.Message From EventLog E Where E.EventID = O.ID
       AND E.Type = 'BOLcn' Order by E.ModTime Desc RANGE 1 TO 1) CarrierName
 From Orders O
Order By O.Date Desc, O.OrderNumber
Tue, Jan 21 2020 5:51 PMPermanent Link

Terry Swiers

Hi Greg,

Your first sub-select is trying to pull a single field from a second sub-select rather than a table or a view.

Replace "(SELECT Message, type, Modtime FROM EventLog Where EventID = O.ID)" with a table or view and it should parse correctly.
Image