Count Rows Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dejavous
    New Member
    • May 2007
    • 1

    Count Rows Help

    Hi there, I'm a SQL Server 2000 noob and looking for some help.

    I need to make a simple script that counts the number of rows in a table.

    Also, i need to make another version ofthe same script, but ONLY look and count rows with certain data in them...e.g. search and count for rows with the word JOE in them.

    Any help would be really appreciated, and if somebody would be so kind to break down and explain each part of the script i would be VERY grateful.

    Cheers,
    Deja.
  • pradeep kaltari
    Recognized Expert New Member
    • May 2007
    • 102

    #2
    Originally posted by Dejavous
    Hi there, I'm a SQL Server 2000 noob and looking for some help.

    I need to make a simple script that counts the number of rows in a table.

    Also, i need to make another version ofthe same script, but ONLY look and count rows with certain data in them...e.g. search and count for rows with the word JOE in them.

    Any help would be really appreciated, and if somebody would be so kind to break down and explain each part of the script i would be VERY grateful.

    Cheers,
    Deja.
    Hi Deja,
    To find out the number of rows in a given table you can use:
    [code=sql]
    SELECT COUNT(*) FROM <table_name>
    [/code]
    This query will return the total number of rows in the table. If you want to find out the number of rows with certain data in them then you can specify that in WHERE clause.
    [code=sql]
    SELECT COUNT(*) FROM <table_name> WHERE col1=value
    [/code]

    You can specify other columns in the WHERE clause by using the AND or OR operator.

    I hope this helps.

    Regards,
    Pradeep

    Comment

    Working...