Print Page | Close Window

SQL Script, stuck

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=8174
Printed Date: 30 March 2026 at 12:16pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: SQL Script, stuck
Posted By: michael
Subject: SQL Script, stuck
Date Posted: 17 December 2003 at 3:39pm

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




Replies:
Posted By: michael
Date Posted: 17 December 2003 at 3:42pm

Just to clarify currently it returns something like:
callhour    AllCalls    et          ct          mt          pt
----------- ----------- ----------- ----------- ----------- -----------
8           ; 1           ; 0           ; 0           ; 0           ; 0
9           ; 8           ; 0           ; 0           ; 0           ; 0
10          17          0           ; 0           ; 0           ; 0
11          18          0           ; 0           ; 0           ; 0
12          9           ; 0           ; 0           ; 0           ; 0
13          12          0           ; 0           ; 0           ; 0
14          14          0           ; 0           ; 0           ; 0
15          12          0           ; 0           ; 0           ; 0
16          10          0           ; 0           ; 0           ; 0
17          9           ; 0           ; 0           ; 0           ; 0
18          1           ; 0           ; 0           ; 0           ; 0
19          0           ; 0           ; 0           ; 0           ; 0
20          0           ; 0           ; 0           ; 0           ; 0
21          0           ; 0           ; 0           ; 0           ; 0

(14 row(s) affected)

Thus all et, ct etc supposed to have values of course.



-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net