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
 SQL Server Development (2000)
 2 longest match on a query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-16 : 09:28:14
woodman writes "Hi sir,

I would like to ask how would the query look like
if I would like to find the one with longest match of a_code1 and a_code2 ?

eg. table A
column a_code1
column a_code2
column dummy

My query select dummy from A
where a_code1 = (select max(a_code1) from A
where &code1 like a_code1||'%')
and a_code2 = (select max(a_code2) from A
where &code2 like a_code2||'%')

Any suggestion about it ?
Thanks very much for your help!"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-16 : 10:15:54
Can you please post some sample data and an expected rowset? The word 'longest' and the use of the max() function in your query don't seem to jive.

<O>
Go to Top of Page
   

- Advertisement -