If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > SQL COUNT Statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-15-04, 11:25
thatdude thatdude is offline
Registered User
 
Join Date: Apr 2004
Posts: 73
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.
Reply With Quote
  #2 (permalink)  
Old 07-15-04, 13:19
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 12,327
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On