Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

I have a challanging query problem

Enthusiast ,
Dec 18, 2008 Dec 18, 2008
I have a challanging problem. I have a datetime column and a numerical column. I need a query that returns a set of the average of the numerical column per month.

Note my data is spread over years so I need to group by mm yy
TOPICS
Database access
580
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 18, 2008 Dec 18, 2008
The best I can come up with so far is:

SELECT SUBSTRING(CONVERT(VARCHAR(8), valueDate, 3), 4, 5) AS mmyy
,avg(rate)
FROM [commercial].[dbo].[OTT_DEALS]
group by valueDate
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 18, 2008 Dec 18, 2008
LATEST
Wait a minute I think this is it:

SELECT SUBSTRING(CONVERT(VARCHAR(8), valueDate, 3), 4, 5) AS mmyy
,avg(rate)
FROM [commercial].[dbo].[OTT_DEALS]
group by SUBSTRING(CONVERT(VARCHAR(8), valueDate, 3), 4, 5)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources