If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Distinct values

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-03-06, 13:20
trex2000 trex2000 is offline
Registered User
 
Join Date: Aug 2006
Posts: 12
Distinct values

Hi all:
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:
Quote:
select distinct c.link1,
a.CardHolderId,a.CardNumber,a.Deleted,
b.RecordId,b.FirstName,b.LastName,b.Deleted,b.Note 4,
c.param3,c.param2,c.param1,c.recvtime,c.gentime,li nk2,c.link3,c.deleted
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On