max and count function

Results 1 to 2 of 2

Thread: max and count function

  1. #1
    Join Date
    Dec 1969

    Default max and count function

    i am new in sql.i need to obtain the maximun no of day from my sql server .For example<BR><BR>my sql database may look like below:<BR>startdate (stored as datetime)<BR>---------<BR>1/20/2001<BR>1/20/2001 5:00<BR>1/20/2001 4:00<BR>1/21/2001<BR><BR>how can i get the maximun no of startdate<BR>startdate NoOfDay<BR>--------- -------<BR>1/20/2001 3<BR><BR>thank for any help.

  2. #2
    Join Date
    Dec 1969

    Default RE: max and count function

    Hi Mike<BR><BR>for the grouping:<BR><BR>select distinct startdate, count(Startdate) from Table Group by Startdate<BR><BR>gives you eg:<BR><BR>1999-10-31 00:00:00.000 1<BR>2000-01-12 00:00:00.000 1<BR>1999-12-23 00:00:00.000 1<BR>2000-07-16 00:00:00.000 9<BR>1999-05-10 00:00:00.000 6<BR><BR>for max:<BR><BR>select Max(StartDate) from Table<BR><BR> <BR>--------------------------- <BR>2001-01-22 00:00:00.000<BR><BR>(1 row(s) affected)<BR><BR><BR>Hope that helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts