Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

select list because it is not contained in either an aggregate function or the GROUP BY clause.

$
0
0

I wrote sp like below,

Alter procedure First_Proc
  (@fromdate datetime,
  @todate datetime
  )
  as
  begin
  select DATEPART(YY,ModifiedDate) as Year
        ,DATEPART(QQ,ModifiedDate) as Quarter
        ,DATEPART(MM,ModifiedDate) as Month
        ,Name
        ,rowguid              
   from [AdventureWorks2012].[Production].[ProductModel]
  where ModifiedDate between (@fromdate) and (@todate)
  group by DATEPART(YY,ModifiedDate),DATEPART(QQ,ModifiedDate),DATEPART(MM,ModifiedDate)
  order by DATEPART(YY,ModifiedDate),DATEPART(QQ,ModifiedDate),DATEPART(MM,ModifiedDate)
  end

But am getting following Error...

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


Can anyone one help me?

Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>