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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Incorrect Syntax Error

Author  Topic 

suketu9
Starting Member

13 Posts

Posted - 2006-12-04 : 12:31:20
I am trying to run this query but keep getting "Incorrect Syntax near keyword 'AS'. Not sure what is wrong:

select bbr_object_name,
DATEPART(day, bbr_value_date) AS 'day',
DATEPART(month, bbr_value_date) AS 'month',
DATEPART(year, bbr_value_date) AS 'year',
DATEPART(hour, bbr_value_date) AS 'hour',
avg("Value") AS 'average',
stdev("Value") AS 'stdev',
count * AS 'count'
from icBoaSwitchLastTransferFV
group by datepart(day, bbr_value_date),
datepart(month, bbr_value_date),
datepart(year, bbr_value_date),
datepart(hour, bbr_value_date),
bbr_object_name
order by year,
month,
day,
bbr_object_name

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-12-04 : 12:42:12
count(*)
not
count *

Be One with the Optimizer
TG
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-04 : 13:40:22
Also, what is about the double quotes (") for the column name Value?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-12-04 : 13:58:19
yeah,

My own preferences and I believe best practices are:

refer to (and alias) column names with square brackets:
select [value] as [stdev]

and only use single quotes for quoted strings (and to ESCAPE an appostrophe):
select 'O''Connell' as [LastName]

and never use double quotes in t-sql code (even though BOL examples use them)

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -