SELECT Id, Name, Address, AnnualRevenue, ConvertedAccount.Id, ConvertedAccount.Name,
ConvertedContact.Id, ConvertedContact.Name, ConvertedOpportunity.Id, ConvertedOpportunity.Name,
TYPEOF Owner WHEN User THEN Id, Name, Account.Id, Account.Name, Account.GL_Treatment__c, Account.GL_Treatment__r.Id, Account.GL_Treatment__r.Name, Account.auto_number_test_1__c ELSE Id END
FROM Lead
Not sure the best structure, but something like this might be nice
SELECT Id, Name, Address, AnnualRevenue, ConvertedAccount.Id, ConvertedAccount.Name,
ConvertedContact.Id, ConvertedContact.Name, ConvertedOpportunity.Id, ConvertedOpportunity.Name,
TYPEOF Owner
WHEN User
THEN Id, Name, Account.Id, Account.Name, Account.GL_Treatment__c, Account.GL_Treatment__r.Id,
Account.GL_Treatment__r.Name, Account.auto_number_test_1__c
ELSE Id
END
FROM Lead
Description
Not sure the best structure, but something like this might be nice