September 15, 2008 at 5:43 pm
I'm new here, so i this is in the wrong forum I apologize.
Question:
Let's say I have two columns. A date, and a number that can repeat itself. If I want the earliest date for the last time entering somenum 1. How do I write that in SQL? I've thrown analytical functions, group bys, havings, you name it at it.
Eg.
date,somenum
'08/05/2008',1
'08/06/2008',1
'08/07/2008',1
'08/08/2008',2
'08/09/2008',2
'08/10/2008',1
'08/11/2008',1
I need 8/10/2008. In other words, the first date for the last time we were at somenum 1.
I want to do this in a select. No loops or cursors.
Any ideas?
September 15, 2008 at 9:40 pm
You probably need code like
SELECT somenum, min (date)
from yourtable
group by somenum
September 16, 2008 at 12:17 am
for the last time entering somenum 1
Please clarify
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply