SQL Count

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ra220511
    New Member
    • Oct 2007
    • 11

    SQL Count

    I am Fairly new to Sql.
    I'm currently trying to write a store procedure to select data from a table(celebtopt en) in my db.

    i need to write a line of code which will count the number of entries in the Table(celebtopt en) and display it based on an id(celebTTId) .
    i also need it to place this value into (NumAnswer)

    id appreciate any help
  • hariharanmca
    Top Contributor
    • Dec 2006
    • 1977

    #2
    Originally posted by ra220511
    I am Fairly new to Sql.
    ............... ...
    I think belo code will help you
    [CODE=sql]
    declare @NoEntry integer
    set @NoEntry = (Select inNull(Count(*) ,0) from tblTableName)[/CODE]

    Comment

    • Shashi Sadasivan
      Recognized Expert Top Contributor
      • Aug 2007
      • 1435

      #3
      Originally posted by ra220511
      I am Fairly new to Sql.
      I'm currently trying to write a store procedure to select data from a table(celebtopt en) in my db.

      i need to write a line of code which will count the number of entries in the Table(celebtopt en) and display it based on an id(celebTTId) .
      i also need it to place this value into (NumAnswer)

      id appreciate any help
      You could also use

      [CODE=sql]select count(*) as NumAnswer from celebtopten where celebtopten.cel ebTTId='theCele bId'[/CODE]

      cheers

      Comment

      • ra220511
        New Member
        • Oct 2007
        • 11

        #4
        Originally posted by Shashi Sadasivan
        You could also use

        [CODE=sql]select count(*) as NumAnswer from celebtopten where celebtopten.cel ebTTId='theCele bId'[/CODE]

        cheers
        this works grand thanks

        Comment

        Working...