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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-11-03 : 07:49:10
|
| Anthony Laportta writes "HiI am triying to obtain the next free value of a column in a table with a SQL.For example supose that the table is T1 and de column C1C1--12457The result in this case must be 3.The following SQL program works fine but it is very slow.Do you know another solution?select bbfrom ( select x as aa,count(y) as bb from ( select a.C1 as x,b.C1 as y from T1 a, T1 b where a.C1 >= b.C1 group by a.C1,b.C1 ) vista1 group by x) vista2where aa<>bblimit 1Bye and thanks in advanceAnthony Laportta" |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2003-11-03 : 08:10:42
|
| select top 1 * from customer a left join customer bon a.code = b.code + 1where b.code is nullorder by a.code |
 |
|
|
|
|
|