mail@pastecode.io avatar
a month ago
2.3 kB
use first;
select * from employeeinfo;
-- write down the query for fetch the records which address =null
select * from employeeinfo where address is null;

order by clause:
order by clause is used for sort the records in ascending and decending order.
syntax:- select * from tablename order by clolumn_name asc/desc;

select * from employeeinfo order by name desc;

when we short data in any filter condition we use where and order by clause;
sequence is mandatory:
1 where
2.order by

ex: select * from employeeinfo where salary=20000 order by name desc;

select * from employeeinfo order by name desc ,address asc;

Aggreate function:-

1 count:- return the total numbner of records.
syntax: select count(columnname) from tablename

ex: select count(*) from employeeinfo;

select count(*) from employeeinfo where salary=30000;
select  count(address) from employeeinfo;
select  distinct count(address) from employeeinfo;
select   count(address) from employeeinfo where salary=30000;
2. min:-return minimum value
select min(salary) from employeeinfo ;
select min(name) from employeeinfo ;
3.max:-return maximum value
select max(salary) from employeeinfo;
select max(name) from employeeinfo where address="pune";
4.avg:- return average og numeric value.
select avg(column_name) from tablename;
select avg(salary) from employeeinfo;
select avg(salary) from employeeinfo where salary > 30000;
5.sum: return total sum of  numeric column.
select sum(columnname) from employeeinfo where condition;
select sum(salary) from employeeinfo
select sum(salary) from employeeinfo  where salary > 30000;

Leave a Comment