ylkien Posted February 23, 2007 Share Posted February 23, 2007 Hi, I am trying to get some data from a MS SQL database. The problem is that there are duplicate 'productid' exist. I would like to get the first 'id' from the 'productid' that occurs (based on first occurance). For example, 'productid=22255805' occurs 2 times, with the 'id's 171866567 & 171868977. But, based on the time, i would only like to select 'id=171866567' cause it occurs first. Thanks! Here is a sample of the data. id productid startedtime 171866567 22255805 2/15/2007 18:57:52 171868977 22255805 2/15/2007 19:23:38 171865835 22255809 2/15/2007 18:41:04 171866604 22255809 2/15/2007 19:04:15 171867946 22255809 2/15/2007 19:17:46 171867078 22255811 2/15/2007 19:11:34 171867659 22255844 2/15/2007 19:15:45 171866565 22255845 2/15/2007 18:56:24 171868611 22255845 2/15/2007 19:21:43 171867380 22255846 2/15/2007 19:13:50 171866554 22261980 2/15/2007 18:54:12 171868291 22261980 2/15/2007 19:19:49 171866578 22261995 2/15/2007 19:01:07 171869743 22261995 2/15/2007 19:27:27 171869333 22261998 2/15/2007 19:25:32 171870202 22261999 2/15/2007 19:29:23 Quote Link to comment https://forums.phpfreaks.com/topic/39757-eliminating-retrieving-duplicate-data/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.