How do I call a User Defined Function to use with select, group by, order by?

前端 未结 1 627
自闭症患者
自闭症患者 2020-12-11 02:35

I have Table1 and I need to get it to look like Table2:

Table1

VisitingCount |  Date
-----------------------
      1       |  15:09
      3       |           


        
相关标签:
1条回答
  • 2020-12-11 03:12

    You can join to your table like a view and have your function call there. That way you can call the group by and order by on the column from the view.

    select
        Count(Page) as VisitingCount,
        [Time]
    from
    (
        SELECT
            Page,
            Date,
            [user],
            dbo.fn_GetActivityLogsArranger(CONVERT(VARCHAR(5),Date, 108)) as [Time]
        FROM
            scr_SecuristLog
    ) scr_SecuristLog2
    where
        Date between '2009-04-30' and '2009-05-02'
    and
        [user] in
    (
        select
            USERNAME
        from
         scr_CustomerAuthorities
        where
            customerID=Convert(varchar,4)
        and
            ID=Convert(varchar,43)
    )
    group by
        [Time]
    order by
        [Time] asc 
    
    0 讨论(0)
提交回复
热议问题