making an aggregate function

  • select isNull(OverT.OverTH,0)as Hours

    from OverT

    where convert(Date,OverT.AttendDate) between '2011-11-01' And '2011-11-30'

    group by OverT.AttendDate

    OverT is OverTime Table, in which OverTH, OverTimeHours are here for employees.

    is it possible to make OverTH an aggregate function. BUT there sholud be no effect on its answer, it gives error as OverTH is invalid in the list, because it is not included in any aggregate function or by the group by cluase.

    I dont want to include it in group by cluase, as it effect the results

  • Please provide table def, sample data and expected result as decribed in the first link in my signature. It will be much more helpful than a verbal description...;-)



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Why are you grouping if you aren't using any aggregate functions? Maybe you're actually looking for SUM(ISNULL(OverT.OverTH,0)) grouped by AttendDate?

  • And...this sort of looks like a simplified reposting of this: http://www.sqlservercentral.com/Forums/Topic1215790-391-1.aspx

    I'm going to second LutzM and strongly suggest that you provide DDL, sample data, and an example of your desired output in order to help us help you better... 😀

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply