MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.

ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Download and Activate to enter!

Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.

Learn More!


Download to Enter
| Contest Rules

Tutorials | Forums

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 4th, 2012, 10:48 AM
sprotson sprotson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 2 sprotson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 5 sec
Reputation Power: 0
Help with 15 minute count query

I am a novice when it comes to SQL. I am basically able to build reports using the query builder but have been asked to do something more complex.

Essentially I have a table with two columns, DateAdded and Name. The "Name" column contains a list of system names and "DateAdded" contains the date/time the system was updated.

Name DateAdded
CME 05/10/2010 11:44
Routing Rules 05/10/2010 11:54
WFM 05/10/2010 11:54
Avaya 05/10/2010 12:04
CME 05/10/2010 12:04
Avaya 05/10/2010 12:04
CME 05/10/2010 12:04
Routing Rules 05/10/2010 12:04
WFM 05/10/2010 12:04
Avaya 05/10/2010 12:54



I need to produce a stored procedure that returns the number of changes per 15 minute interval per system.


CME Routing Rules WFM Avaya
11:30 1
11:45 1 1
12:00 2 1 1 2
12:15
12:30
12:45 1


I have been given the following code to help. It seems to return the number of changes, but does not split it down by system. The person who gave me the code is not available to help me further - can anyone assist.


ALTER procedure [dbo].[ChangesByIntervalGK]
@in_date datetime
as
begin
declare @timesteps table (interval varchar(5), howmany int)

declare @num int
select @num = 0
while @num < 96
begin
insert into @timesteps values (convert(varchar(5), dateadd(minute, @num*15, 0),8), 0)

select @num = @num + 1
end

select innerquery.interval, max(innerquery.howmany) howmany from
(

select * from @timesteps

union

select
convert(varchar(5), dateadd(minute, datediff(minute,0,Addeddate) / 15 * 15, 0), 8) interval,
count(*) howmany

from ConfigurationItemLatest

where Addeddate between @in_date and dateadd(day, 1, @in_date)
group by convert(varchar(5), dateadd(minute, datediff(minute,0,Addeddate) / 15 * 15, 0), 8)

) innerquery

group by innerquery.interval

end

Reply With Quote
  #2  
Old February 4th, 2012, 06:02 PM
fubes2000's Avatar
fubes2000 fubes2000 is offline
manwich
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Canadanistan
Posts: 575 fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 388781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 388781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 388781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 388781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 388781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 388781 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 10 h 47 m
Reputation Power: 382
Someone might want to move this over to the MSSQL forum, since that's what this is.

You should be able to change the grouping by adding the 'name' column to both the SELECT and GROUP BY lines.
__________________

Reply With Quote
  #3  
Old February 5th, 2012, 08:13 AM
sprotson sprotson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 2 sprotson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 5 sec
Reputation Power: 0
Quote:
Originally Posted by fubes2000
Someone might want to move this over to the MSSQL forum, since that's what this is.

You should be able to change the grouping by adding the 'name' column to both the SELECT and GROUP BY lines.


Thanks for trying to help. As a complete novice to SQL, I notice that there seems to be several selects and group bys.

Any help with the code or suggestion as to where I should be making the changes would be appreciated.

Apologies if this is posted in the wrong place, just desperate for help

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Help with 15 minute count query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap