SQL Server Performance

What is causing this error in SQL Express for AdventureWorks2012 database?

Discussion in 'ALL SQL SERVER QUESTIONS' started by Rock_query, Mar 24, 2013.

  1. Rock_query New Member

    Here is my code:

    SELECTAVG(ListPrice)ASavrg,

    ProductLine,

    SellStartDate

    FROMProduction.Product

    Msg 8120, Level 16, State 1, Line 13

    Column 'Production.Product.ProductLine' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

    

    1. What am I doing wrong?
    2. Which SQL version is used on SQL Express? Is it standard SQL, T-SQL, something else?
  2. Shehap MVP, MCTS, MCITP SQL Server

    Welcome to Forums ..

    For any aggregative query , we have usually 2 kinds of columns :

    · Aggregative columns which are passed for aggregation functions either count , sum,avg,Min, Max…etc

    · The rest of columns which should be used within Group by at the end of query

    SO your query should be written like this :

    SELECTAVG(ListPrice)ASavrg,

    ProductLine,

    SellStartDate

    FROMProduction.Product group by ProductLine,SellStartDate

    And all of SQL Server versions are based on the same T-SQL Standards but additional codes and functions are added within each version like Merge commands added within SQL Server 2008 and Fetch & Offset commands added within SQL Server 2012 …etc

    Kindly let me know if any further help is needed

Share This Page