HI,
I've to write stored procedures for count the records based on some conditions.For example,I have table with name,address,number,new totally 4 fields.Here "new" field is filled by True or False.Now i've to write stored procedures to count the records which have "True" in "new" field and which have "False" in "new" field.Can anyone help me to do this?
Loading

Kiresh GangariyaPosted Jun 17, 2013, 1:46 AM
SELECT
Count(Id) AS TotalCount FROM TableName where new = 1 UNION SELECT Count(Id) AS TotalCount FROM TableName where new = 0
Kiresh GangariyaPosted Jun 17, 2013, 2:11 AM
Kavi sujaPosted Jun 17, 2013, 2:02 AM
Kavi sujaPosted Jun 17, 2013, 2:02 AM
Sunny SharmaPosted Jun 17, 2013, 1:42 AM
use the pattern below:
-------------------------------
CREATE PROCEDURE CountRecords
AS
BEGIN
SELECT COUNT(name) FROM MyTable where new=0;
END
---------------------------
Hope it helps :)