Jump to content

MIN MAX


karr4
 Share

Recommended Posts

  • 2 weeks later...

You want to try this

create table product
(
  p_id int primary key,
  prod_name  varchar(20),
  price varchar(5)
  );

insert into product values(1,"Milk",100);
insert into product values(2,"Buttermilk",120);
insert into product values(3,"Paneer",80);
insert into product values(4,"Cheese",150);
insert into product values(5,"Ghee",700);

select * from product

You can get the max price from table

SELECT prod_name, MAX(price)
FROM product
GROUP BY prod_name;

You can get min price from table

SELECT prod_name, MIN(price)
FROM product
GROUP BY prod_name;

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...