Select B From (Select B,C From Table1) not working

  • My query looks like this:

    SELECT Avg(Income) FROM

    (SELECT Customer.InnerID, Customer.Type, Sum(Insurance_Season.Cost) as Income

     FROM Customer, Insured_Customer, Insurance_Season, Insurance_Policy

     WHERE Customer.InnerID = Insured_Customer.InnerID

     AND Insured_Customer.PolicyID = Insurance_Policy.PolicyID

     AND Insured_Customer.Role = 'PH'

     AND Insurance_Policy.PolicyID = Insurance_Season.PolicyID

     AND Insurance_Season.Begin_date > '1/1/2004'

     GROUP BY Customer.InnerID, Customer.Type)

    and all I get is "Incorrect syntax near ')'."

    Is this not possible in SQL Server or what am I missing? I have tried simpler versions, I can't even get

    SELECT Customer.InnerID FROM (Select Customer.InnerID FROM Customer)

    to work.

     

  • Hi Jerry!

    Without solving your first question the correct syntax for the second query should be:

    SELECT   c.InnerID

    FROM     (SELECT Customer.InnerID FROM Customer) c

     


    robbac
    ___the truth is out there___

  • Thank you.

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

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