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 > Database Server Software > Microsoft SQL Server > First value

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-11-06, 13:50
trex2000 trex2000 is offline
Registered User
 
Join Date: Aug 2006
Posts: 12
Unhappy First value

Hi all:
I have to generate a query so that the first value return me of the I gave by each employee in a rank dated and rank of cards, they are in a board of history, but I have not been able to achieve it since the consultation that generate a single value returns me does not return me the values of all the employees, that I was doing badly?, someone to help me say as achievement to do this?

It's a Sql Server 2000.

The table and the field is History.Link1

I used the next code:

Quote:
Select Top 1 History.Link1,Card.CardHolderId,Card.CardNumber,Ca rd.Deleted,
CardHolder.RecordId,CardHolder.FirstName,CardHolde r.LastName,CardHolder.Note4,CardHolder.Deleted,
History.Param3,History.Param2,History.Param1,Histo ry.RecvTime,History.Gentime,History.Link2,History. Link3,History.Deleted
From Card
Left Join CardHolder On Card.CardHolderId=CardHolder.RecordId
Left Join History On CardHolder.RecordId=History.Link3
Where (Card.Deleted = 0)And(CardHolder.Deleted = 0)And(History.Deleted = 0)
And(Card.CardNumber Between 1500 And 1600)
And(History.RecvTime >= Convert(DateTime,'2006-09-15 00:00:00',102))And (Recvtime <= Convert(DateTime,'2006-09-30 23:59:59',102))
And(History.Link1 = 10)Or(History.Link1 = 12)Or(History.Link1 = 15)Or(History.Link1 = 17)
And CardHolder.Note4 <> 'Mantenimiento'
Order By Card.CardNumber
Thanks.
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