group by/left outer join problem

  • I was wondering whether anyone could spot why my 'group by' function is "incorrect Syntax" from the following query I'm running. The only thing that is highlighted as incorrect syntax by SQL Server is the "GROUP" by SQL Server. If anyone has proposed solution, I would really appreciate it!

    SELECT 0.SignedData, accountID, COUNT(*) AS NumOrder,

    CASE WHEN COUNT(domain_name) <= 5 THEN '1-5'

    ELSE CASE WHEN COUNT(domain_name)<= 10 THEN '6-10'

    ELSE CASE WHEN COUNT(domain_name)<= 50 THEN '11-50'

    ELSE CASE WHEN COUNT(domain_name)<= 100 THEN '51-100'

    ELSE CASE WHEN COUNT(domain_name)<= 500 THEN '101-500'

    ELSE CASE WHEN COUNT(domain_name)<= 1000 THEN '501-1000'

    ELSE '1001 or more' END END END END END END

    FROM [ Sandbox].dbo.[2011.07.01_all]

    Left Outer Join [ Sandbox].[dbo].[factable]AS fac

    ON [SignedData]= SignedData;

    GROUP BY accountID

    order by NumOrder desc

    ~Annie

  • You have a ; before your group by. Thus you have nothing for the group by to work against.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Thanks! The colon was grayed out and I didn't notice.

  • You are welcome.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

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

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