Help with Error:Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

  • SELECT DISTINCT(USER_ID) FROM marketing_dataset WHERE EMAIL_CAMPAIGN IN (SELECT TOP 1 with ties SUM(REGISTER_WEBINAR)/COUNT(DISTINCT (USER_ID)) AS CONV,EMAIL_CAMPAIGN

    FROM marketing_dataset

    GROUP BY EMAIL_CAMPAIGN

    ORDER BY CONV DESC)

    How to get rid of the error "Only one expression can be specified in the select list when the subquery is not introduced with EXISTS." ? I am trying to execute the above query.

  • Ditch the aggregate. You are returning two columns in the subquery, while you can have only one in an IN clause.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • SELECT DISTINCT(USER_ID) FROM marketing_dataset WHERE EMAIL_CAMPAIGN IN

    (SELECT TOP 1 WITH TIES EMAIL_CAMPAIGN

    FROM marketing_dataset

    GROUP BY EMAIL_CAMPAIGN

    ORDER BY SUM(REGISTER_WEBINAR)/COUNT(DISTINCT (USER_ID)) DESC)

    Thanks a lot man, You guided me to solve the puzzle I had been dealing with for the last few hours. It makes sense now 🙂

  • OK, great you solved your issue and thanks for posting back.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply