none
Group By RRS feed

  • Pergunta

  • Estou tentando agrupar por Produto mas está dando um erro: Column 'sales.Movement.MovementID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

    O código: 

    SELECT        TOP (100) PERCENT sales.Movement.MovementID, sales.Movement.SchoolID, sales.Movement.PeriodID, sales.Movement.ProductID, 
                             commons.Product.Name AS Produto, sales.Movement.UserAdminID, [authorization].UserAdmin.Name AS Usuário, sales.Movement.TypeSaleID, 
                             sales.TypeSale.TypeSale, sales.Movement.Date, sales.Movement.Quantity, sales.Movement.Price, sales.Movement.PCName
    FROM            sales.Movement INNER JOIN
                             sales.Period ON sales.Movement.PeriodID = sales.Period.PeriodID AND sales.Movement.SchoolID = sales.Period.SchoolID AND 
                             sales.Movement.UserAdminID = sales.Period.UserAdminID INNER JOIN
                             commons.Product ON sales.Movement.SchoolID = commons.Product.SchoolID AND sales.Movement.ProductID = commons.Product.ProductID INNER JOIN
                             [authorization].UserAdmin ON sales.Movement.UserAdminID = [authorization].UserAdmin.UserAdminID INNER JOIN
                             sales.TypeSale ON sales.Movement.TypeSaleID = sales.TypeSale.TypeSaleID
    WHERE        (sales.Movement.TypeSaleID = 1)
    GROUP BY commons.Product.Name

    Poderiam ajudar?

    Obrigado

    sexta-feira, 23 de maio de 2014 16:10

Respostas