Subject | Help with SQL Query |
---|---|
Author | William Gonzáles Sánchez |
Post date | 2007-09-24T17:57:18Z |
Hello everybody. I have 2 tables:
1)
ACTIVITIES
ID ORDER_NUMBER MATERIAL DATE_TIME
------------------------------------------------------------------------------
100 OF200709FR-0556 3240HD-48 14.09.2007 15:53:53
101 OF200709FR-0556 511 14.09.2007 16:00:55
2)
TEMPERATURES
ID ACTIVITY_ID TEMPO_01 TEMPO_02 TEMPO_03
1000 100 144 153
100
1001 100 146 151
101
1002 100 151 150
110
1003 100 162 148
106
1004 100 159 145
110
1005 100 163 146
107
1007 101 144 153
120
1008 101 146 151
115
1009 101 151 150
125
1010 101 162 148
123
1011 101 163 147
135
1012 101 159 145
103
In ACTIVITIES table, I have the main rows. Each row in ACTIVITIES, has 6
"child" rows in TEMPERATURES. I need a sql query that gives me these
results:
ACTIVITIES.ID ORDER_NUMBER MATERIAL DATE_TIME
TEMP_01_AV TEMP_02_AV TEMP_03_AV
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
100 OF200709FR-0556 3240HD-48
14.09.200715:53:53 120 130
110
101 OF200709FR-0556 511
14.09.2007 16:00:55 115 125
104
As you can see, I need all fields from table ACTIVITIES and the 6 values
average from table TEMPERATURES (TEMP_01_AV, TEMP_02_AV,TEMP_03_AV) for each
activity.
Please, help me to do the SQL query.
Thanks in advance.
William GS
[Non-text portions of this message have been removed]
1)
ACTIVITIES
ID ORDER_NUMBER MATERIAL DATE_TIME
------------------------------------------------------------------------------
100 OF200709FR-0556 3240HD-48 14.09.2007 15:53:53
101 OF200709FR-0556 511 14.09.2007 16:00:55
2)
TEMPERATURES
ID ACTIVITY_ID TEMPO_01 TEMPO_02 TEMPO_03
1000 100 144 153
100
1001 100 146 151
101
1002 100 151 150
110
1003 100 162 148
106
1004 100 159 145
110
1005 100 163 146
107
1007 101 144 153
120
1008 101 146 151
115
1009 101 151 150
125
1010 101 162 148
123
1011 101 163 147
135
1012 101 159 145
103
In ACTIVITIES table, I have the main rows. Each row in ACTIVITIES, has 6
"child" rows in TEMPERATURES. I need a sql query that gives me these
results:
ACTIVITIES.ID ORDER_NUMBER MATERIAL DATE_TIME
TEMP_01_AV TEMP_02_AV TEMP_03_AV
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
100 OF200709FR-0556 3240HD-48
14.09.200715:53:53 120 130
110
101 OF200709FR-0556 511
14.09.2007 16:00:55 115 125
104
As you can see, I need all fields from table ACTIVITIES and the 6 values
average from table TEMPERATURES (TEMP_01_AV, TEMP_02_AV,TEMP_03_AV) for each
activity.
Please, help me to do the SQL query.
Thanks in advance.
William GS
[Non-text portions of this message have been removed]