473,785 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

one for the SQL experts - dare I say TRICKY SQL!

Guys,

Hopefully someone can help.

We have a monitoring program that has threads which start and stop
monitoring at various times. There are two tables:

THREADLIFECYCLE

unique_id
start_time (always populated)
end_time (not populated until the thread ends)
MONITORRESULTS

unique_id
time_of_measure ment
value
What I am trying to do is find the average value for each of the
numbers of running threads. To explain further, threads will start,
stop independently and overlap each other.

I want an output that says:

When 1 thread was running: average value was x
When 3 threads were running: average value was y

Due to the start and stop nature there could be 1 thread running at the
beginning of the test, mid way through, a number of occassions, etc.

Also, the number of threads does not necessarily ramp sequantially -
the number running at any time could be like this sequence: 1, 5, 10,
7, 12, 4, 2

ANY help would be much appreciated - it really has stumped me but looks
like it should be so simple .... But aren't they always the hard ones
;-(

Thanks

Graham

Feb 7 '06
22 1747
Tony Rogerson wrote:
Standard to which DBMS? Certainly not Oracle. I will submit passing
date strings without a proper format specifier is poor coding:


The ISO standard rather than vendor specific.
INSERT INTO Threads ( thread_id, start_stamp, stop_stamp )
VALUES(1, convert(datetim e, '2006-02-07 02:03:00', 120),
convert(datetim e, '2006-02-07 02:07:00', 120))


You do not and would not code it like that in SQL Server, you would simply
write...

INSERT INTO Threads ( thread_id, start_stamp, stop_stamp )
VALUES(1, '2006-02-07T02:03:00', '2006-02-07T02:07:00') [snip]


Not sure which difference you mean.

The whole purpose of using the ISO 8601 format is that you don't need to
specify the converting mode. So I would omit it too.

But I would probably also specify the datetime as '2006-02-07 02:07:00'.
I still use SQL 7.0, and this format is upwards compatible. The format
'2006-02-07T02:07:00' is harder to read, and needs at least SQL Server
2000.

Gert-Jan
Feb 11 '06 #21
Gert-Jan Strik (so***@toomuchs pamalready.nl) writes:
But I would probably also specify the datetime as '2006-02-07 02:07:00'.
I still use SQL 7.0, and this format is upwards compatible. The format
'2006-02-07T02:07:00' is harder to read, and needs at least SQL Server
2000.


But '2006-02-07 02:07:00' is subject to different interpretations depending
on dateformat settings. For instance try:

SET LANGUAGE Dutch
go
SELECT convert(datetim e , '2006-02-07 02:07:00')
go
SET LANGUAGE Swedish
go
SELECT convert(datetim e , '2006-02-07 02:07:00')
go

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Feb 11 '06 #22
Erland Sommarskog wrote:

Gert-Jan Strik (so***@toomuchs pamalready.nl) writes:
But I would probably also specify the datetime as '2006-02-07 02:07:00'.
I still use SQL 7.0, and this format is upwards compatible. The format
'2006-02-07T02:07:00' is harder to read, and needs at least SQL Server
2000.


But '2006-02-07 02:07:00' is subject to different interpretations depending
on dateformat settings. For instance try:

SET LANGUAGE Dutch
go
SELECT convert(datetim e , '2006-02-07 02:07:00')
go
SET LANGUAGE Swedish
go
SELECT convert(datetim e , '2006-02-07 02:07:00')
go


You are right, I made a mistake. I would have written '20060207
02:07:00', which has no such side effects. So Tony was right: under
normal circumstances, no one would use "convert(dateti me, '2006-02-07
02:03:00', 120)" on SQL Server.

Gert-Jan
Feb 11 '06 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
2214
by: dracolytch | last post by:
Good day all, Ok, I have a pretty tricky problem that I need some help with. I pass around search query information a fair amount (specifically WHERE statements). Normally, I just rawurlencode() the buggers, and pass them via the URL. I like having the where clauses in the URL, because then someone can just bookmark the URL, or send it to a friend, and I don't have to worry about a thing. If someone does a search that requires a LIKE...
5
4595
by: TimS | last post by:
I am getting a baffling File not found error (0x800A0035). I am writing asp on a windows 2000 server. I build a path and filename from several fields in a jet database using SQL commands, like this: Sql = "SELECT dirs.rootname,dirs.dirname FROM dirs" RS.open Sql RS.movefirst do while not RS.EOF temp1=trim(RS("rootname"))
1
13778
by: JZ | last post by:
Oracle 9iR2 I have a table: SQL> select * from test; A B C ------------------- ---------- ---------- 01/01/2004 10:00:00 1 1 01/01/2004 11:00:00 1 2
4
1912
by: Bung | last post by:
Hi, I have a tricky sql statment I have to write (tricky for me) and I am stuck. I'm having trouble with the following problem. Table1 (Column a, Column b, Column c) Table2 (Column a, Column b, Column c) Table3 (Column a, Column b, Column c) Table1 contains a row of value (1, 2, 3)
22
2565
by: ByteSize | last post by:
Dear All, Please, this is not meant to be offensive - but it is a challenge !!! I have posted on over a dozen so called 'vb.net' expert / blog sites - in the vain hope of finding a complete, accurate and ACTUALLY FUNCTIONING snippet to demonsrate a successful api call to CreateProcess() using VB.NET. So far NO ONE has taken up the challenge - not even MSDN or MS personnel. I have code that works in vb6, I have dilligently tried to...
7
2436
by: VB Programmer | last post by:
I am using the BitBlt operation to capture various controls into jpegs. It's almost like a screen capture, but of just the control. (This is a VB.NET application.) Because of BitBlt limitations I know that the application has to always be on top. The problem: I am running this application on a Windows Server 2003 PC. The server is in another state (North Carolina). I am in Florida. I access the server over Termincal Server /Remote...
5
2349
by: Johnny Ljunggren | last post by:
Hello all I've got this tricky situation that I would like to solve in SQL, but don't know how to do. This is the table: Id = 3, VId = 2, Time1 = 10:00, Time2 = 14:00 Id = 4, VId = 2, Time1 = 16:00, Time2 = 17:00 Id = 5, VId = 2, Time1 = 18:00, Time2 = 19:00 Id = 6, VId = 2, Time1 = 20:00, Time2 = 21:00 Id = 7, VId = 3, Time1 = 11:00, Time2 = 13:00
2
1735
by: cfriedalek | last post by:
OK, I've asked this earlier this week with no response. Since then I've also received a suggestion from the app developers but that failed with the same type error problem. Hopefully Mark Hammond or other experts can offer a suggestion as to how to get around this problem. I'm foolish enough to think that a solution can be found. Or can someone suggest how to pm Mark. --------------------------- I'm using pywin32com to drive a 3rd...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9481
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.