March 2, 2012 at 11:13 am
This is what i have in table
No code
5 4
4 4
3 2
2 4
1 4
I need to retrive the oldest No.something like min(No) but it is not followed by "code" 2. If the code 4 is followed by 2 then retrive 4 prior to that code 2.
No code
5 4
4 43 2
2 4
1 4
i need to retrieve the above bolded record.
if i have found "0" in the "code"...for example
No code
5 4
4 4
3 0
2 4
1 4
then the code 4 follwed by "0" continue down for oldest "No".
No code
5 4
4 4
3 0
2 4
1 4
I need to retrive the above bolded record.
Could any one help me out how to write the script for this one.
Thanks in advance.
March 2, 2012 at 12:30 pm
Hi and welcome to SSC. It is very unclear what you trying to do here. Take a look at the first link in my signature about how to best post questions to get you an answer.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
March 3, 2012 at 10:01 am
Also, please define what you mean by "oldest No".
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply