vladfrenkel
Programmer
Hi, I got the following question.
I got 2 tables in Lets say A and B
Structures of the tables are:
"A" table "B" Table
OldName Number New_name Number Value Time
Time field in "B" table in following format "YYYY-MM-DD HH24:MI:SS"
So knowing the alias I can easily create a query:
select A.New_Name,A.Old_Name,B.Value,B.Time from A,B where A.Number = B.Number AND B.Time BETWEEN '2003-12-01' AND '2004-01-30' AND (A.New_Name like '%mw%' OR A.New_Name like '%mv%');
Everything worked so far. But, cause Value probe in "B" table happening every 3 minutes, and Name entries are about 10000 in the table,identified by '%mv" and '%mw', I simply cannot get some much data (imaging 60 days * 60min/3min * 24 * 10000 and you will get the magic number of rows. Tried to run it throught Database client or Vbscript ADO connections it is taking about 4 hours to complete. Cause I'm having 20 tables like that on 20 independent servers it is simply unacceptable for a time frame. So, we dicided instead of each minute to get an average for an each hour. I cannot get an average throught Vbscript (programmatically), cause it will not improve the database dump performance, I've to do it throught SQL. And here is the problem, I'm very familiar with MySQL logic and syntaksis, but this is my first time I'm querying Microsoft SQL server. Tried to construct the query - didn't work.
So result of my query should look like that
Time Name Value
01-30-04 00:00 abbmw 10
01-30-04 01:00 bbccmv 20
01-30-04 02:00 cccmvar 30
and so on.
Can somebody help me with this ?
Thank you very much.
Sincerely
vladfrenkel
I got 2 tables in Lets say A and B
Structures of the tables are:
"A" table "B" Table
OldName Number New_name Number Value Time
Time field in "B" table in following format "YYYY-MM-DD HH24:MI:SS"
So knowing the alias I can easily create a query:
select A.New_Name,A.Old_Name,B.Value,B.Time from A,B where A.Number = B.Number AND B.Time BETWEEN '2003-12-01' AND '2004-01-30' AND (A.New_Name like '%mw%' OR A.New_Name like '%mv%');
Everything worked so far. But, cause Value probe in "B" table happening every 3 minutes, and Name entries are about 10000 in the table,identified by '%mv" and '%mw', I simply cannot get some much data (imaging 60 days * 60min/3min * 24 * 10000 and you will get the magic number of rows. Tried to run it throught Database client or Vbscript ADO connections it is taking about 4 hours to complete. Cause I'm having 20 tables like that on 20 independent servers it is simply unacceptable for a time frame. So, we dicided instead of each minute to get an average for an each hour. I cannot get an average throught Vbscript (programmatically), cause it will not improve the database dump performance, I've to do it throught SQL. And here is the problem, I'm very familiar with MySQL logic and syntaksis, but this is my first time I'm querying Microsoft SQL server. Tried to construct the query - didn't work.
So result of my query should look like that
Time Name Value
01-30-04 00:00 abbmw 10
01-30-04 01:00 bbccmv 20
01-30-04 02:00 cccmvar 30
and so on.
Can somebody help me with this ?
Thank you very much.
Sincerely
vladfrenkel