Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Each GROUP BY expression must contain at least one

Author  Topic 

vinay.varala
Starting Member

3 Posts

Posted - 2012-09-06 : 06:08:07
create proc sp_hrdate
@red datetime
as
begin
declare @Reading_Date datetime
set @Reading_Date=@red

select DatePart(hour,@Reading_Date) as hour, convert(Date,@Reading_Date,103) as date, avg(Fuel_Level)as fuel_level,avg(Fuel_Volume)as fuel_volume from Levels
where Simmons_PanelID=5479
group by DatePart(hour,@Reading_Date),convert(Date,@Reading_Date,103)
order by DatePart(hour,@Reading_Date)
end
can anyone help me in get rid of this

cheers..

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2012-09-06 : 06:49:42
comment the group by clause and try
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-09-06 : 06:56:34
Removing the GROUP BY clause will stop SQL from complaining. However, I think there is more to the query than what you have in there. The parameter @red being provided means something doesn't it? What are you trying to calculate? The levels and volumes within that hour? Or levels and volumes for a range? The way you have written the query now, the calculations are not using the parameter at all.

If you describe what you are trying to calculate, someone on the forum would be able to suggest required changes.
Go to Top of Page
   

- Advertisement -