Thread: Distinct values
10-03-06, 14:20 #1Registered User
- Join Date
- Aug 2006
Unanswered: Distinct values
I am a developing an application wich reads the values of Sql Server 2000 that come from readings sensors, now the problem is that they want two different reports to the ones that already have, one summarized and another detailed but, I have the problem in the summarized doing the sentence Sql,what we need is the following thing:
Of the sensor 10.- The first value of the day.
Of the sensor 12.- Tha last value of the day.
Of the sensor 15.- The first value of the day.
Of the sensor 17.- The last value of the day.
And in this sentence should be just thes 4 readings, of course the data of employee in a rank dated
Any one who can help me?
The code of the sentence that utilize is the following:
select distinct c.link1,
from card a ,cardholder b,history c
where ((a.cardholderid = b.recordid)And (b.recordid=c.link3))And(a.Deleted = 0)And (b.Deleted = 0)And(a.cardnumber Between 1500 And 2000)
And(c.RecvTime >= CONVERT(DATETIME, '2006-09-15 00:00:00', 102))And(c.RecvTime <= CONVERT(DATETIME, '2006-09-30 23:00:00', 102))
And(c.Link1=10 Or c.Link1=12 Or c.Link1=15 Or c.Link1=17)
And(b.note4 <> 'Mantenimiento')
order by a.cardnumber