Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have to fetch the count(*) from the table where the date =06/22/2012

my query is

SQL
alter procedure sp_prodcount
 @SubSite_Id int,
 @callattend varchar(100),
 @callstart1 datetime
  
as
begin

SELECT  count(*) as '22nd june' FROM  Process_Details
WHERE  (SubSite_Id = @SubSite_Id) AND (Call_Attended = @callattend) 
AND  call_start >=(SELECT distinct CONVERT(VARCHAR(10),@callstart1,101)from process_details) 
end

EXECUTE  sp_prodcount 88,'FarheenS','06/22/2012'



Need urgent help
tnks in advance,
Posted
Updated 27-Jun-12 23:02pm
v2

Why don't you create a start datetime as your datecomponent@midnight, and an end datetime, as your datecomponent@2359 then do a start<call_start<end
 
Share this answer
 
v2
if i correctly undersatnd your question..
you want count that how many call attented on peticular DATE

try below query:-

SQL
SELECT count(*) as '22nd june' FROM Process_Details
WHERE (SubSite_Id = @SubSite_Id) AND (Call_Attended = @callattend) 
AND CONVERT(VARCHAR(10),call_start,101)  = CONVERT(VARCHAR(10),@callstart1,101)
 
Share this answer
 
SQL
Create Procedure SP_ProdCount
	@SubSite_Id int,
	@callattend varchar(100),
	@callstart1 datetime
As  
Begin
 
SELECT	Count(*) '22nd june'
FROM	Process_Details
WHERE	(SubSite_Id = @SubSite_Id)
AND	(Call_Attended = @callattend) 
AND	DATEDIFF(D, call_start, @callstart1) >= 0 -- date of 'call_start' is equal or higher than @callstart1 date

End
 
EXECUTE  SP_ProdCount 88,'FarheenS','06/22/2012'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900