Group by date part

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 30-Oct-2006 14:51:36   

Hi,

I'm trying to create a set of months for which a blogger has written an entry plus the number of entries for each month.

So I believe I need to group by month and year of a date field and then count the posts.

How do I go about doing this with LLBLGen?

Cheers, Ian.

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 30-Oct-2006 15:05:30   

Or this....

ALTER PROCEDURE [dbo].[sp_GetBlogEntryDates]

    @bloggerID int

AS
BEGIN

SELECT
    Datepart("month", Date) as "Month",
    Datepart("yy", Date) as "Year",
    count(*) as "Count"

FROM
    tbl_BlogEntry

WHERE
    BloggerID = @bloggerID
    AND
    Live = 1

GROUP BY
    Datepart("yy", Date), Datepart("month", Date)

ORDER BY
    Year DESC, Month DESC
Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 30-Oct-2006 16:00:42   

Hi,

please read the following thread for how to handle "month" and "year" in your predicates:

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=3829

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 30-Oct-2006 20:59:41   

Ok thanks.