• edited by
2,307 views
2 2 votes

Can we apply min and max (aggregate function in sql) on strings and date datatype ?

Query :SELECT max(Name) FROM EMPLOYEE

what will be the result ?

2 Answers

Best answer
2 2 votes

Yes ,we apply Max,MIn Function function on string and date date type.

In case of String data type-The functions Max ,Min, etc. use the lexicographic order when applied to text columns.

If Query is-

SELECT MAX(`type`) FROM 'Product`;

Output-

Printer

In PC and Laptop case: "P" symbol goes after "L" symbol(P>L) so MAX result is PC. Printer and PC: first letters are equal (P=P)but "r" symbol goes after "C"(r>c) so MAX result is Printer.

In case of Date data type-

Query-SELECT MAX(return_date)  FROM `movies`;

Output- 

25-06-2012

above query give latest date.

From your Table and query result is- 'F'

• selected by
Position:
Show:

Related questions

2 2 votes
1 1 answer
2.4k
2.4k views
rohan mishra asked Jul 8, 2017
2,436 views
Given a column consisting of 12,19,12,13,14,NULL,NULL. What will be the answer1.If we apply count on the column.2.If we apply sum on the column.3.If we apply avg on the ...
0 0 votes
1 1 answer
1.9k
1.9k views
gateexplore asked Jun 30, 2023
1,862 views
Considering the following schema, create the appropriate tables and insert at least 5 records:AUTHOR(author-id,name, city,country)PUBLISHER (publisher-id, name,city, coun...
0 0 votes
1 1 answer
502
502 views
Satbir asked Dec 4, 2018
502 views
please give an example to differentiate between self join , natural join and join operation.
1 1 vote
1 1 answer
825
825 views
Harikesh Kumar asked Jan 13, 2018
825 views
Provide the correct answer