473,387 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Get the latest result (new in sql)

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
Aug 11 '06 #1
5 2198
lipsa
35
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
Aug 11 '06 #2
Banfa
9,065 Expert Mod 8TB
And also use ORDER BY and LIMIT clauses to order by date (most recent first) and limit the return result to 1 record.
Aug 11 '06 #3
iam_clint
1,208 Expert 1GB
Banfa i do believe LIMIT is mysql

I am pretty sure its TOP in sql server.
Aug 11 '06 #4
iam_clint
1,208 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. select top 1 * from <table> where <date_column> like '%yyyy%' order by <date_column> desc
  2.  
So this should do what your looking for i would think.
Aug 11 '06 #5
Banfa
9,065 Expert Mod 8TB
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
Aug 11 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: adolf garlic | last post by:
Im trying to return xml from sql. The xml is made up of different fragments, some using FOR XML ... syntax. The result is a valid xml doc. There is a working stored proc that returns the xml In...
1
by: Todd Peterson | last post by:
I'm a newbie to DB2 and am trying to figure out how to write a stored procedure, using dynamic SQL statements to return a result set. I believe the majority of the hurdles I have been facing might...
15
by: AussieRules | last post by:
Hi, I have a need to do two selects against to stored proc's in my SQL db. At the moment, each SP is called and two different dataset are populate. Thats two round trips to the SQL server. ...
24
by: clare at snyder.on.ca | last post by:
I have a SQL query I need to design to select name and email addresses for policies that are due and not renewed in a given time period. The problem is, the database keeps the information for every...
8
by: TGEAR | last post by:
I have an ItemSTDPriceHistory table as below and this is a child table of itemlookup table with one to many relationship. if exists (select * from dbo.sysobjects where id = object_id(N'.') and...
3
by: Lenard Redwood | last post by:
I am trying to create a PHP script that queries entries from a MySQL table: <?php $user="myusername"; $password="mypassword"; $database="mydatabase"; mysql_connect(localhost,$user,$password);...
4
by: Mark | last post by:
Hey folks, I'm looking at making the following query more efficient potentially using the ranking functions and I'd like some advice from the gurus. The purpose of the following is to have a...
0
by: Yasin | last post by:
Walt <walt@boatnerd.com.invalidwrote in message news:<3F0C5BA9.DB809458@boatnerd.com.invalid>... You can use below sql for your result select * from test; PERSON_ID DAT TIME CODE...
8
by: stbdk | last post by:
Hi I don't know how to discribe my problem in sql language, as I'm new to this :-) but here is my problem database test animal---city-------place---number----time ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.