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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Select Query to get the Max value

Author  Topic 

reddymade
Posting Yak Master

165 Posts

Posted - 2005-05-13 : 16:58:55
I have the table Tasks: and fieldname is Taskcode:

In the Taskcode: i can enter .01 or .01.102 or .01.102.103 etc

So i have to find searching all rows in that table to that field to see where maximum points are.
each point represents one level:

if it is .01 only it is only one level since it has only one point in it.

if it is .01.12.14 then it has three levels, i see there are three points in it.

once i establish the maximum levels then i can do the other stuff.

Can you please tell me, is it possible to get that info.

Table name is Tasks and field name is Taskcode.

Please Help, Thank you very much for the information.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-05-14 : 00:38:39
This doesn't seem like a very good design but here is one answer to your question:

select taskcode
,[level]
from (
select taskcode
,len(taskcode) - len(replace(taskcode,'.','')) [level]
from tasks
) a
Where [level] = (select max(len(taskcode) - len(replace(taskcode,'.',''))) from @tasks)


Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -