Viewing 15 posts - 7,081 through 7,095 (of 8,731 total)
Maybe it can become clearer if you work with 2 CTEs.
WITH Months AS(
SELECTDATEADD(MM, DATEDIFF( MM, 0, GETDATE()) - N, 0) startdate
FROM (VALUES (6),(5),(4),(3),(2),(1)) x(N)
),
MonthData AS(
SELECT LEFT( DATENAME(MONTH, startdate), 3) AS...
January 29, 2014 at 12:54 pm
You previously posted a way to use only the month without the year.
Here's another way.
SELECT LEFT( DATENAME(MONTH, DATEADD(MM, DATEDIFF( MM, 0, GETDATE()) - N, 0)), 3) month_name,
January 29, 2014 at 12:51 pm
You could just change the month_name column definition to your original code using datename.
January 29, 2014 at 12:28 pm
As I told you, you can build a "calendar table" on the fly. This will work for 6 months, but you may need to increase it if the requirement changes....
January 29, 2014 at 11:43 am
It means that you ignored the first reply to your post made by me.
While I'm here, do you want to include a validation to include months without data?
You could easily...
January 29, 2014 at 11:10 am
born2achieve (1/29/2014)
thanks for your reply. actually the avg gives in terms of decimal. i just rounded and shown as result.
But on your query where is the condition to...
January 29, 2014 at 10:54 am
I was thinking on how to do it with a CASE statement, but as you said, the code might have been complicated with multiple ignore and all those columns. I'm...
January 29, 2014 at 10:41 am
All this reminds me of my weirdest day regarding the weather (all in Mexico so under the 41st parallel:-P). I had to leave Chihuahua at 6am with -4°F(-20°C), arrived to...
January 29, 2014 at 10:30 am
Could you post DDL and sample data in a consumable format?
This should be easy but I don't want to spend half an hour formatting to create a test table...
January 29, 2014 at 10:20 am
I won't get to the exact data you posted as expected output, but I suppose it's not correct and you just included some numbers.
Here's an option.
select DATEADD(MM, DATEDIFF( MM, 0,...
January 29, 2014 at 10:11 am
BCP NBC (1/29/2014)
As long as there are developers (without DBA mind-set) creating databases out there, and I see it almost every day, there will be the need for DBAs.
That's a...
January 29, 2014 at 8:38 am
Now you're not including the target data type. Have you opened the link I provided?
And you are missing the SELECT statement.
Tip: If you select a function and press F1, you'll...
January 28, 2014 at 6:12 pm
The issues you're facing are all covered in this book: Troubleshooting SQL Server: A Guide for the Accidental DBA[/url].
Take a look and make it your faithful companion.
EDIT: And be sure...
January 28, 2014 at 6:07 pm
Have you tried it?
It might not return the expected results because you're not including your variable in the function.
January 28, 2014 at 5:56 pm
ScottPletcher (1/28/2014)
January 28, 2014 at 5:45 pm
Viewing 15 posts - 7,081 through 7,095 (of 8,731 total)