Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.3 kB
14
Indexable
Never
Limit:- 

select * from Customers where country ='UK' limit 1;
select * from Customers where country ='UK' order by customer_id desc limit 1;

offset:-
syntax:-select * from table_name limit offset, rownumber;
select * from Customers  limit 3, 2;

select * from Customers  order by first_name  limit 3, 2;

for insert multiple value:

insert into Customers values(6,"John","Doe",45,	"USA"),
(7,	"Robert",	"Luna",	22,	"USA");



Agreagate function:-
count()
min()
max()
sum()
avg()

1 . count: 
select distinct count(*) from Customers ;
select distinct count(*) from Customers where first_name="John";
select distinct count(age) from Customers ;
select  count(*) as count from Customers ;


max:-max fuction is used in all columns(numeric + string)
string: max function is works on asschi value of character.
select max(first_name) from Customers;

min :- 
select min(first_name) from Customers;
select min(first_name) from Customers where age=22;

sum():used in only numeric column
select sum(amount) as sum from Orders
select sum(amount) as sum from Orders where amount>300;

avg():-used only numeric column
select avg(amount) as sum from Orders;
select avg(amount) as sum from Orders  where amount>300;

Leave a Comment