Solved

SQL max command

Posted on 2011-02-14
2
852 Views
Last Modified: 2012-05-11
I have the follwoing data in the table.

wID
WS-1000
IS-1001
MS-10001

Two letters, a hyphen then number 4 to 5 digits. How can I select the maximum number from the digit part?

thanks

ayha
0
Comment
Question by:ayha1999
2 Comments
 
LVL 9

Accepted Solution

by:
s_chilkury earned 250 total points
ID: 34890219
Try:
SELECT @NId = MAX(CAST(SUBSTRING(field, 4, len(field)) as INT))  FROM [table];
0
 
LVL 7

Author Closing Comment

by:ayha1999
ID: 34890295
thanks
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware ā€“ malware that gets on your customersā€™ computers, encrypts their data, and extorts a hefty ransom for the decryption keys ā€“ is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now