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 2005 Forums
 Transact-SQL (2005)
 how to use Like between columns

Author  Topic 

azharrahi
Starting Member

44 Posts

Posted - 2007-04-30 : 06:46:50

Hope you all will be fine.
I have Two Tables Insurant(IID, PolicyNo, PolicyTypeID) and PolicyType(PolicyTypeID, PolicyTypeName, PolicyTypeCode)
Now Insurant contains the ID of PolicyType
I want that Max(IID) must be retrieved for each of PolicyCode of PolicyType. e.g. there are 8 policyTypes and I want that against each code The max(IID) must be retrieved from Insurant Table.
Van any body tell me the query and solve my problem.
Thanks

Azhar Rahi
Software Engineer
Experts Desk Pvt Ltd,Lahore
Pakistan

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-30 : 06:49:32
select t2.polictypecode, max(t1.iid)
from policytype as t2
inner join insurant as t1 on t1.policytypeid = t2.policytypeid
group by t2.polictypecode


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

azharrahi
Starting Member

44 Posts

Posted - 2007-04-30 : 06:49:32
Sorry I left some useful info as well ...
the PolicyNo is created using PolicyCode of Policytype. I want to retrieve Max(IID) from Insurant where there is a PolicyNo concatenated with the specific PolicyCode of PolicyType.

Azhar Rahi
Software Engineer
Experts Desk Pvt Ltd,Lahore
Pakistan
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-30 : 06:54:33
It would be more clear if you could post some sample data and expected output.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

azharrahi
Starting Member

44 Posts

Posted - 2007-04-30 : 07:12:08
I have got the solution of my own so feel no need to query any more. By the way thanks for reply

Azhar Rahi
Software Engineer
Experts Desk Pvt Ltd,Lahore
Pakistan
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-30 : 07:13:06
It would be the proper thing to share the solution for other to benefit from this.
Unless your solution is very similar to the one I posted 04/30/2007 : 06:49:32?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -