Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To get the maximun value

Status
Not open for further replies.

runa12345

IS-IT--Management
Jul 13, 2006
9
0
0
US
Hi All,
I have data in this way:

Example:

Type, Value
A, 122
A, 136
A, 126
B, 111
B, 156
C, 187
C, 163
C, 145
my output should be :

Type, Value
A, 136
B, 156
C, 187

I have 10000 rows based on the type and max(value) i like to select rows. I am new to sql,can any help me in getting the query.

Thanks in advance



 
select
type
,max(value)
from
tab1
group by
type;

This will give you the maximum value for each type.

Similarly, replace max by min, avg, sum to get the minimum, accumulated total and average for each type.

If you only want the types with a value higher than the average, add the phrase:

having max(value) > avg(value)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top