February 28, 2012 at 4:27 am
Hi All,
I guess it is row processing logic I'm after, where the returned value is calculated on the fly. I'll be counting up instances of each weekday type. What is important is that each date is a month, and for that month I want to parse the days and count those daytypes.
The output will be:
Month, Weekday, DayCount
2010-01-01, Friday, 5
2010-01-01, Saturday, 5
2010-01-01, Sunday, 5
...
And so there'll be 7 rows per month.
Anyway conceptually, I wanted to see if you can do something like this ? Inserting code where a column selection would go. It appears you can't, so I wonder how else to attack this problem ?
---
SELECT month, weekday,
BEGIN
DECLARE @i INT = 0, @dte DATETIME
WHILE @i < 32
IF ISDATE(STUFF(@dte, 9,2,@i)
IF ISDATE(@dte)
/* link count of daytypes to "weekday" here, or something...*/
@i = @i + 1
END
FROM Table
---
February 28, 2012 at 4:50 am
Most likely, you don't need looping in what you are trying to achieve!
If you would post your question in line with the forum etiquette, I believe you will get relevant help in no time.
Please follow the link at the bottom of my signature...
If you are too lazy to do the above, I can advice you to search for "quirky update" article by Jeff Moden on this site. Looks like it's relevant to your problem.
February 28, 2012 at 7:41 am
Thanks, I sorted it out myself - sorry to waste your time.
Regards, Greg.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply