Results 1 to 15 of 15

Thread: count per all entry divide / total count

Threaded View

  1. #4
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: count per all entry divide / total count

    ok,
    i think about something and i wish this can help.
    vb Code:
    1. SELECT COUNT(Custstatus),dbo.TotalCount() as TotalRows FROM <TableName>
    2. GROUP By Custstatus

    where dbo.TotalCount() is Scalar Valued Function
    and here is its Definision
    vb Code:
    1. USE [<your Database>]
    2. GO
    3. /****** Object:  UserDefinedFunction [dbo].[TotalCount]    Script Date: 08/24/2009 10:47:02 ******/
    4. SET ANSI_NULLS ON
    5. GO
    6. SET QUOTED_IDENTIFIER ON
    7. GO
    8. CREATE Function [dbo].[TotalCount]()
    9. RETURNS int
    10.  
    11. AS
    12. BEGIN
    13.     DECLARE @Return int
    14.     SET @Return = (SELECT COUNT(*) FROM dbo.<yourTableName>)
    15.     return @Return
    16. END
    Last edited by avrail; Aug 24th, 2009 at 03:50 AM. Reason: there was something missing
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

Posting Permissions

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



Click Here to Expand Forum to Full Width