Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in SQL Server only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
SQL Server
Get the latest result (new in sql)
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
Casper2
New Member
Join Date:
Aug 2006
Posts:
2
#1
Get the latest result (new in sql)
Aug 11 '06, 05:15 AM
I have a huge table with multiple record for one patient but I only want the latest
result within a year. How can I do it?
thanks, :confused:
Casper2
lipsa
New Member
Join Date:
Aug 2006
Posts:
35
#2
Aug 11 '06, 06:36 AM
hi,
what cloumns are there in ur table,if u hv date colun then u can easily do that
with where ...LIKE,IN clauses
select * from <table> where <date_column> like '%yyyy%'
Regards,
Lipsa
Comment
Post
Cancel
Banfa
Recognized Expert
Expert
Join Date:
Feb 2006
Posts:
9067
#3
Aug 11 '06, 01:02 PM
And also use ORDER BY and LIMIT clauses to order by date (most recent first) and limit the return result to 1 record.
Comment
Post
Cancel
iam_clint
Recognized Expert
Top Contributor
Join Date:
Jul 2006
Posts:
1207
#4
Aug 11 '06, 09:13 PM
Banfa i do believe LIMIT is mysql
I am pretty sure its TOP in sql server.
Comment
Post
Cancel
iam_clint
Recognized Expert
Top Contributor
Join Date:
Jul 2006
Posts:
1207
#5
Aug 11 '06, 09:17 PM
Code:
select top 1 * from <table> where <date_column> like '%yyyy%' order by <date_column> desc
So this should do what your looking for i would think.
Comment
Post
Cancel
Banfa
Recognized Expert
Expert
Join Date:
Feb 2006
Posts:
9067
#6
Aug 11 '06, 10:02 PM
Originally posted by
iam_clint
Banfa i do believe LIMIT is mysql
I am pretty sure its TOP in sql server.
That's good to know since I am just about to start using SQL Server at work :D
Thank You
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment