How to get maximum value of a specific part of strings?

extract maximum numeric value from a given string
extract maximum numeric value from a given string in c++
how to get max value from varchar sql
find largest number in string java
maximum value of string
get numeric value from string c
get max value from string in sql
how to get only numeric values from string c

I have below records

Id         Title 
500006     FS/97/98/037                                                                                                                                                                                                                                                     
500007     FS/97/04/035                                                                                                                                                                                                                                                    
500008     FS/97/01/036                                                                                                                                                                                                                                                     
500009     FS/97/104/040 

I should split Title field and get 4th part of text and return maximum value. In this example my query should return 040 or 40.

select max(cast(right(Title, charindex('/', reverse(Title) + '/') - 1) as int))
from your_table
SQLFiddle demo

Arrange a binary string to get maximum value within a range of , Given a string consisting of only 0's and 1's. Now you are given N non- intersecting ranges L, R ( L <= R), more specifically [L1, R1], [L2, R2], …, [LN, RN] , No two� To get a maximum value based on criteria, you can use the MAX function together with the IF function in an array formula. In the example shown, the formula in cell G6 is: { = MAX ( IF ( names = F6 , times )) } Where names is the named range B6:B17,

You can use PARSENAME function since you always have 4 parts(confirmed in comments section)

select max(cast(parsename(replace(Title,'/','.'),1) as int)) 
   from yourtable 

select max value from a string column in SQL, Remove the letters and cast it as an int then get the max. Given that it will always be Ord-### we can remove the Ord- and cast the remainder as an INT. SELECT MAX(CAST(SUBSTRING(OrderNo,5,LEN(OrderNo)-4) AS INT))� To get a maximum value based on criteria, you can use the MAX function together with the IF function in an array formula. In the example shown, the formula in cell G6 is: { = MAX ( IF ( names = F6 , times )) } Where names is the named range B6:B17,

If you want to split the data in the Title column and get the part from the splitted text by position, you may try with one JSON-based approach with a simple string transformation. You need to transform the data in the Title column into a valid JSON array (FS/97/98/037 into ["FS","97","08","037"]) and after that to parse thе data with OPENJSON(). The result from OPENJSON() (using default schema and parsing JSON array) is a table with columns key, value and type, and the key column holds the index of the items in the JSON array:

Note, that using STRING_SPLIT() is not an option here, because the order of the returned rows is not guaranteed.

Table:

CREATE TABLE Data (
   Id varchar(6),
   Title varchar(50)
)
INSERT INTO Data
   (Id, Title)
VALUES
   ('500006', 'FS/97/98/037'),                                                                                                                                                                                                                                                    
   ('500007', 'FS/97/04/035'),                                                                                                                                                                                                                                                    
   ('500008', 'FS/97/01/036'),                                                                                                                                                                                                                                                  
   ('500009', 'FS/97/104/040')

Statement:

SELECT MAX(j.[value])
FROM Data d
CROSS APPLY OPENJSON(CONCAT('["', REPLACE(d.Title, '/', '","'), '"]')) j
WHERE (j.[key] + 1) = 4

If you data has fixed format with 4 parts, even this approach may help:

SELECT MAX(PARSENAME(REPLACE(Title, '/', '.'), 1))
FROM Data

How to get the maximum value from strings with integers in MySQL?, Since the string is filled with string and integer, fir example, “STU201”, therefore we need to use CAST(). with alphanumeric strings beginning with specific characters in MYSQL? Following is the query to get the maximum value − mysql> select MAX(CAST(SUBSTRING(StudentBookCode FROM 4) AS� Let’s see how can we can get n-largest values from a particular column in Pandas DataFrame. Observe this dataset first. We’ll use ‘Age’, ‘Weight’ and ‘Salary’ columns of this data in order to get n-largest values from a particular column in Pandas DataFrame.

You can also try the below query.

SELECT Top 1 
    CAST('<x>' + REPLACE(Title,'/','</x><x>') + '</x>' AS XML).value('/x[4]','int') as Value
from Data
order by 1 desc

You can find the live demo Here.

Finding the minimum and maximum value from a string with , Use MIN() function along with SUBSTRING() for minimum, whereas MAX() for maximum. Let us first create a table −mysql> create table� Part 1: Here we have a string local variable and assign it to a string literal. We print the length of that data. Part 2: An empty string literal is used. The length of an empty string is always 0. Part 3: A string that uses the "const" modifier also has a length—this is the same as a literal.

Python max() Function, Definition and Usage. The max() function returns the item with the highest value, or the item with the highest value in an iterable. If the values are strings,� Strings (C# Programming Guide) 06/27/2019; 12 minutes to read +12; In this article. A string is an object of type String whose value is text. Internally, the text is stored as a sequential read-only collection of Char objects.

Java, In this example we are finding out the maximum and minimum values from an int array. class MinMaxExample { public static void main(String args[]){ int. z.pop(1) removes the value at index 1 and returns the value 4. The pop method removes an item at the index you provide. This method will also return the item you removed from the list. If you don’t provide an index, it will by default remove the item at the last index. z = [7, 4, 3, 3] print(z.pop(1)) print(z)

Finding the Maximal/ Minimal String, Based on Alphabetic Order in , Now, we want to return the number that carries the maximum value. Follow below given steps:- Select the cell B1 and write the formula. =MAX(A1:A4); Press Enter � Pandas : How to merge Dataframes by index using Dataframe.merge() - Part 3; Pandas : Convert a DataFrame into a list of rows or columns in python | (list of lists) Pandas : Merge Dataframes on specific columns or on index in Python - Part 2; Pandas: Convert a dataframe column into a list using Series.to_list() or numpy.ndarray.tolist() in python

Comments
  • Does your data always contain 4 parts of text?
  • yes It's always 4 parts.
  • I think that you need to replace / with . to use PARSENAME correctly.
  • @juergend overlooked the /, fixed.
  • @Zhorov - yep, fixed.