|
I think I have been looking at too much code today but got stuck on below SQL Script. Basically the problem I have is, that it does not give me any data for time zones (just zeros), the 'AllCalls' returns values correctly so I guess I am getting messed up with the join. Maybe someone sees right away what is going on, I need to take a break from it  The code is not clean yet, It is in test mode as more will be added, Stored Procedure Creation commented out so I can test run the query till it returns the values I want. Thank for any help.
[CODE]
--Create Procedure apx_CallVolume
--(
Declare @seldt datetime
Declare @prod varchar(20)
Set @seldt = '01/08/2003'
Set @prod = 'Accounts Payable'
--)
--AS
--Declaration of TimeZones
Declare @et varchar(150)
Declare @ct varchar(150)
Declare @mt varchar(150)
Declare @pt varchar(150)
--Assigning TimeZones to States
Set @et = 'FL,GA,SC,NC,KY,VA,DC,WV,DE,MD,PA,OH,MI,NJ,NY,CT,RI,MA,NH,VT ,ME'
Set @ct = 'AL,MS,LA,TX,TN,AR,OK,IL,MO,KS,IA,NE,SD,ND,MN,WI'
Set @mt = 'NM,CO,UT,WY,ID,MT'
Set @pt = 'CA,NV,OR,WA'
If month(@seldt) >= 4 AND day(@seldt) >= 4 AND month(@seldt) <= 10 AND day(@seldt) <= 31
BEGIN
Set @ct = @ct + ',IN'
SET @pt = @pt + ',AZ'
END
ELSE
BEGIN
Set @et = @et + ',IN'
Set @mt = @mt + ',AZ'
END
Declare @temptbl varchar(50)
Set @temptbl = newid()
Create TABLE #@temptbl
( callhour int,AllCalls int,et int,ct int,mt int,pt int)
--Doing the Query
Declare @rcntr int
Set @rcntr = 8
--Creating the Hour Column
WHILE @rcntr < 22
Begin
INSERT INTO #@temptbl (callhour)
VALUES
(@rcntr)
Set @rcntr = @rcntr + 1
END
--Creating the All Calls Column
SET @rcntr = 8
WHILE @rcntr < 22
BEGIN
Update #@temptbl
Set AllCalls = (
Select Count(*)
from sv_inquiry i
------------- http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker
|