MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMS SQL Development

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 13th, 2012, 08:36 AM
NotJohn NotJohn is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 2 NotJohn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m 40 sec
Reputation Power: 0
MS SQL - Query issue - Any Ideas?

Hi All,

I have a table with data simular to the following in MS SQL

SysName DateTime Status
SysA 01/01/2012 01:00 Up
SysB 01/01/2012 01:00 Down
SysC 01/01/2012 01:00 Up
SysA 01/01/2012 01:10 Up
SysB 01/01/2012 01:10 Down
SysC 01/01/2012 01:10 Down
SysA 01/01/2012 01:20 Down
SysB 01/01/2012 01:20 Down
SysC 01/01/2012 01:20 Down
SysA 01/01/2012 01:30 Up
SysB 01/01/2012 01:30 Down
SysC 01/01/2012 01:30 Up
SysA 01/01/2012 01:40 Up
SysB 01/01/2012 01:40 Down
SysC 01/01/2012 01:40 Up
SysA 01/01/2012 01:50 Down
SysB 01/01/2012 01:50 Down
SysC 01/01/2012 01:50 Up
SysA 01/01/2012 02:00 Down
SysB 01/01/2012 02:00 Down
SysC 01/01/2012 02:00 Up
SysA 01/01/2012 02:10 Up
SysB 01/01/2012 02:10 Down
SysC 01/01/2012 02:10 Up

I need to be able to run a query that will list the the down periods for each SysName in order - so the data from the above would look like the following

SysName DownTime UpTime
SysB 01/01/2012 01:00 STILL DOWN
SysC 01/01/2012 01:10 01/01/2012 01:30
SysA 01/01/2012 01:20 01/01/2012 01:30
SysA 01/01/2012 01:50 01/01/2012 02:10

The main issue I am having is allow the same device to be listed multiple times.

Any help would be greatly appreciated, I'm sure there's a trick to making this work...

Thanks!

Reply With Quote
  #2  
Old February 21st, 2012, 09:48 AM
DeveloperBase DeveloperBase is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Location: Kansas City
Posts: 12 DeveloperBase User rank is Sergeant (500 - 2000 Reputation Level)DeveloperBase User rank is Sergeant (500 - 2000 Reputation Level)DeveloperBase User rank is Sergeant (500 - 2000 Reputation Level)DeveloperBase User rank is Sergeant (500 - 2000 Reputation Level)DeveloperBase User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 h 1 m
Reputation Power: 0
So you want the most recent down record returned for each server?

Code:
select sysname, max(datetime), status
from tablename
where status = 'down'
group by sysname
order by sysname

Reply With Quote
  #3  
Old February 21st, 2012, 11:09 AM
NotJohn NotJohn is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 2 NotJohn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m 40 sec
Reputation Power: 0
Hi,

Thanks for your response.

I need a history of all the down events and the duration of the outage for lets say the last 10 outages, it could be the same node was down twice, this is where the difficulty lies as getting the last outage and duration for each is quite easy by selecting the last down time using max and then finding the max last uptime which is < the max last downtime.

Thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > MS SQL - Query issue - Any Ideas?

Developer Shed Advertisers and Affiliates



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 - 2013, Jelsoft Enterprises Ltd.

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