If you want to know what SQL statement the SQL Server query processor generates based on a regular X++ select statement, you can add to the keyord generateOnly to the statement an afterwards call the getSQLStatement method on the record buffer.
Example:
AccountingEvent accountingEvent;
SourceDocumentHeader sourceDocumentHeader;
select generateonly accountingEvent
join sourceDocumentHeader
where sourceDocumentHeader.RecId == accountingEvent.SourceDocumentHeader;
info (accountingEvent.getSQLStatement());
That turns out something like this:

Like
Report
*This post is locked for comments