Hi

I want to write a query

In my table data like this

sapno plant amt status
a SG20 7 1
b HK10 24 4
a HK10 60 4
b SG50 20 12
a HK10 7 4
c HK10 7 4

if more than one sapno is same value then i should take record whose amt is large.that is i should display only one sapno and corresponding record whose amt is big.

the output of above should be
sapno plant amt status
a HK10 60 4
b HK10 24 4
c HK10 7 4

Regards

Recommended Answers

All 2 Replies

Hey you want to sort just based on amt right
first u use 2 times table aliasing
check comdition
use order-by clause
u can able to make proper quey

select * from table
group by sapno
order by amt desc

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.