www.webdeveloper.com
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008
    Posts
    1

    COUNTIF Equivalent in SQL

    Please excuse me if this is a silly question, but I am from the mainframe world where array processing would solve my problem. I am trying to utilise the equivalent of the Excel =COUNTIF(A1:Z1,"09") statement.

    Say I have 26 columns and need to count the occurence of a particular value (in this example 09) in each table row across these 26 columns. In a tool based on SQL2000 how can this be done?

    Regards

  2. #2
    Join Date
    Aug 2006
    Location
    Michigan
    Posts
    1,046
    Code:
    SELECT COUNT(field)
    FROM table_name
    WHERE field = "09" /* if the value is a string */
    OR

    Code:
    SELECT COUNT(field)
    FROM table_name
    WHERE field = 9 /* if the value is numeric */

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

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



Recent Articles