SQLTeam.com | Weblogs | Forums

New to SQL how to get MAX from Group


#1

+----------+---------+-------+--------+
| Name | Price | QTY | CODE |
+----------+---------+-------+--------+
| Rope | 3.6 | 35 | 236 |
| Chain | 2.8 | 15 | 237 |
| Paper | 1.6 | 45 | 124 |
| Bottle | 4.5 | 41 | 478 |
| Bottle | 1.8 | 12 | 123 |
| Computer | 1450.75 | 71 | 784 |
| Spoon | 0.7 | 10 | 412 |
| Bottle | 1.3 | 15 | 781 |
| Rope | 0.9 | 14 | 965 |
+----------+---------+-------+--------+


#2

select name, max(price)from tab
group by Name


#3

SELECT name,max(price) FROM [tab]
group by (name)

out put........
name max(price)
bottle 4.5
chain 2.8
computer 1450.75
paper 1.6
rope 3.6
spoon 0.7