Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.9 kB
6
Indexable
Never
Having clause:
having clause is uesd for filter the records from the group based on the given condition.
having clause is only used  with select clause.
syntax:- select column() from table_name group by column_name having condition;

ex: select count(*), item from Orders  group by item having count(*)>1;

   select count(*), item from Orders  group by item having count(*)>1 order by item desc;

when we use having ,where,order by ,group by  clause

sequence:
     where 
     group by 
     having
     order by

-----------------------------------------------------------------------------------------------
difference between where and having clause.

where:-1.where caluse is used to filter the data from the table in the specific condition.
       2. where clause cannot cointain aggregate function.
       3.where clause can be used without group by clause.
       4.where clause is used with select,update,delete.
       5.where clause is used before group by clause.
       



having:-1. having clause is uesd for filter the records from the group based on the given condition.
        2. having clause contain aggregate function.
        3. having clause cannot be used without group by clause.
        4. having clause is only used  with select clause.
        5. having clause is used after group by clause.


----------------------------------------------------------------------------------------------------
Trasaction control language:TCL
    commit, rollback
Commit:-
commit is used for the permanentaly save the changes.

syntax :- update tablename set column=values where condition;
          commit;
              

rollback:-rollback command is used for undo/revert the trasaction.
         the cammand is only used to undo changes since the last commits

           update command;
           commit;
           update command ;

           rollback;      
Leave a Comment