fromtheashes462 Posted August 25, 2007 Share Posted August 25, 2007 I need a to write an SQL query that has a columns of: count(col), and count(col) is between x and y; any ideas? Quote Link to comment Share on other sites More sharing options...
vijayfreaks Posted August 25, 2007 Share Posted August 25, 2007 Hi.. you can suppose you want count of product for specific category range.. then select catid, count(product) from product where catid >=1 and catid <=5 group by catid Regards, Vijay Quote Link to comment Share on other sites More sharing options...
fromtheashes462 Posted August 25, 2007 Author Share Posted August 25, 2007 yes but I need a total count and then a count for a specific range. example: id, count(col) all rows, COUNT(col) BETWEEN x and y Quote Link to comment Share on other sites More sharing options...
fenway Posted August 27, 2007 Share Posted August 27, 2007 yes but I need a total count and then a count for a specific range. example: id, count(col) all rows, COUNT(col) BETWEEN x and y Well, assuming you don't want to issue 2 separate queries, just use a SUM()... id, count(col), SUM( IF col BETWEEN x and y, 1, 0 ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.