266
Views
2
Comments
Solved
Sub query does not work within in ISNULL() in SQLObject Advanced Queries
Question

Hi team,


I encountered an error when i called a sub Query with in a ISNULL() in SQL query Syntax in SQL Obecjt Advance Query.

Kindly Help

here is the sample query:

SyntaxEditor Code Snippet

SELECT  {User}.[Id], 
        {User}.[Username], 
        ISNULL({TimelineLockingByUsers}.[AppraiserEditModeFromDate], SELECT {Timelines}.[AppraiserEditModeFromDate] FROM {Timelines} WITH(NOLOCK) WHERE {Timelines}.[Id] = @TimelineId) AS EditModeFromDate, 
        ISNULL({TimelineLockingByUsers}.[AppraiserEditModeTillDate], SELECT {Timelines}.[AppraiserEditModeTillDate] FROM {Timelines} WITH(NOLOCK) WHERE {Timelines}.[Id] = @TimelineId) AS EditModeTillDate
FROM {User} WITH(NOLOCK) 
        INNER JOIN {UserRelations} WITH(NOLOCK) ON {User}.[Id] = {UserRelations}.[UserId]
        LEFT JOIN {TimelineLockingByUsers} WITH(NOLOCK) ON  {UserRelations}.[Id] = {TimelineLockingByUsers}.[UserRelationId] 
                                                        AND {TimelineLockingByUsers}.[TimelineId] = @TimelineId
        WHERE {UserRelations}.[AppraiserId] = @AppraiserId
2019-09-17 09-11-00
João Pedro Abreu
Staff
Solution

You didn't tell us what the error says, but I'm pretty sure the SELECT statements inside the ISNULL function need to be wrapped in parentheses.

2025-02-04 11-46-43
Waseema Shaikh
Staff

João Pedro Abreu wrote:

You didn't tell us what the error says, but I'm pretty sure the SELECT statements inside the ISNULL function need to be wrapped in parentheses.

Thanks Dude! 

It worked for me.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.