Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    73

    Unanswered: SQL COUNT Statement

    I am trying to count records in SQL Server. I have this Stored procedure but I am getting SQL errors.

    Code:
    Alter Procedure usp_rptQualityReport3 As
    
    SELECT * FROM viewQualityReport
    
    SELECT COUNT([FailureReason]) AS FC
    
    WHERE 
    	(((viewQualityReport.FailureReason) <> N'NONE'))
    
    ORDER BY
    	FC
    I am trying to count records that have like FailureReasons. I am selecting all the records from the view I created and then trying to count the records in the second Select statement. Basically what I want to do is counf them so I can then rank them starting with failure reasons that happen the most. I don't know what I am doing wrong.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    SELECT FailureReason, COUNT(*) AS FC
    FROM viewQualityReport
    WHERE FailureReason <> 'NONE'
    GROUP BY FailureReason
    ORDER BY FC desc
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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