Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - SQL Script, stuck
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SQL Script, stuck

 Post Reply Post Reply
Author
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Topic: SQL Script, stuck
    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

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.