Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi every one
i have a table as this :
  Date      Shift    IDType  IDPers    Value
2000/1/1    1          1          1          10
2000/1/1    1          1          2          12
2000/1/1    2          1          1           8
2000/1/1    2          1          2          14
2000/1/2    1          1          2           5
2000/1/2    1          2          1          19
2000/1/2    2          1          2          23
2000/1/2    2          2          1          28

now,i want select last inserted every IDPers as this :

  Date      Shift    IDType  IDPers    Value
2000/1/1    2          1          1           8
2000/1/2    2          1          2          23
2000/1/2    2          2          1          28

but how can i select as above
thank you
Posted
Updated 26-Mar-12 22:35pm
v2
Comments
Amir Mahfoozi 27-Mar-12 6:28am    
Please elaborate on this question because it is not clear what do you mean by saying "last inserted". Is the Date field formatted so that it doesn't show the time part or maybe it is of "Date" data type. So How should we find out what is the last inserted field ?
sinaone 27-Mar-12 10:43am    
first thank you for your response
well we have a shift that it's work shift , so we have many shift in a day
and i want get last time that every IDType+IDPers are registered
for example IdType 1 + IDPers 1 is registerd in Date 2000/1/1 and Shift 2 in last time
so how can i get last time registerd every IDType+IDPers
thank you

1 solution

Select Top 1 * From TableName Order By FieldName Desc
 
Share this answer
 
Comments
sinaone 27-Mar-12 10:46am    
i want get last time registerd every IDType+IDPers
but this select get back just a record
so this is wrong select
but however thank you for your response
[no name] 28-Mar-12 11:14am    
Please try RANK methods or GROUP BY

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900