Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2010-05-14 : 14:29:44
|
| I have field name sequenceno.eaxmple:if i pass 7 as sequence to get max sequence in seven series to check table_orderdetails.i have 7.0, 7.01, 7.02, 7.03then it should get 7.03 is the max is 7 series.Can you please tell me how to wrtite select to get max in that number series.select max(seqNo) from table_orderdetailswhere seqno in series 7Thank you very much for the helpful info. |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-05-14 : 14:37:15
|
| [code]select max(seqno) from table_orderdetailswhere seqno >= @search_intand seqno < (@search_int + 1)[/code]or[code]select max(seqno) from table_orderdetailswhere seqno like convert(varchar(10),@search_int) + '%'[/code]@search_int can be your value that you pass |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2010-05-14 : 15:07:02
|
Are you looking for something like this?CREATE TABLE #myTable99 (id int IDENTITY(1,1), Series decimal(10,2))GOINSERT INTO #myTable99 (Series)SELECT 7.0 UNION ALLSELECT 7.01 UNION ALLSELECT 7.02 UNION ALLSELECT 7.03 UNION ALLSELECT 8.0 UNION ALLSELECT 8.01 UNION ALLSELECT 8.02GO SELECT FLOOR(Series), MAX(Series) FROM #myTable99GROUP BY FLOOR(Series)GODROP TABLE #myTable99GO Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
Posted - 2010-05-14 : 22:58:40
|
| select max(seqNo) from table_orderdetailswhere seqno >= 7 and seqno < 8______________________Mayazar Mori Ke Dane Keshast |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-15 : 03:19:15
|
quote: Originally posted by cplusplus I have field name sequenceno.eaxmple:if i pass 7 as sequence to get max sequence in seven series to check table_orderdetails.i have 7.0, 7.01, 7.02, 7.03then it should get 7.03 is the max is 7 series.Can you please tell me how to wrtite select to get max in that number series.select max(seqNo) from table_orderdetailswhere seqno in series 7Thank you very much for the helpful info.
whats datatype of field containing the values?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|