.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

Find Maximum Length of data in sql server

Posted By: Naresh     Posted Date: May 10, 2010    Points:2   Category :Sql Server
hi,

I need a sql query to find the data with maximum length with same id:

Eg:

id address
2 No 56, I cross, Nethaji Nagar, Chennaai-28, Ph 7687833
no:044 Email id :xx@yahoo.com
2 No 56, I cross, Nethaji Nagar,

i need to get the data with maximum length.

OutPut:
id address
2 No 56, I cross, Nethaji Nagar, Chennaai-28, Ph 7687833
no:044 Email id :xx@yahoo.com

Thanks in Advance.

Responses
Author: Lakhan Pal Garg             
Posted Date: May 10, 2010     Points: 5   

Hi Naresh-
Use this Query:

SELECT ID,MAX(adress) FROM tblYourTable GROUP BY ID 


Thanks
Lakhan Pal Garg

Author: Naresh             
Posted Date: May 10, 2010     Points: 5   

hi pal,

i tried the query but Iam not getting the right answer. the above query gives the data which is present at maximum in table.


Thanks

Thanks
Naresh
Author: Lalij Mer             
Posted Date: May 10, 2010     Points: 5   

Show this link

http://www.plus2net.com/sql_tutorial/sql_max.php

Please Check my answer if you help....
Thank You...

Lalit.
Author: Lakhan Pal Garg             
Posted Date: May 10, 2010     Points: 5   

Hi-

Try this
SELECT ID,MAX(AddressLength) FROM (SELECT ID,LEN(Address) as AddressLength FROM tblYourTable) GROUP BY ID



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend