Page 176 - IT-802_class_12
P. 176

Output:
        +---------------+----------------+------------------+---------------+---------+--------+
        | Emp_NAmE      | Emp_DEpARTmENT | Emp_DESiGNATiON  | DATE_OF_BiRTH | ADDRESS | Emp_iD |
        +---------------+----------------+------------------+---------------+---------+--------+
        | SOmNATH_pATRA | ACADEmiCS      | COmpUTER TEACHER | 2005-05-05    | RANCHi  | Emp05  |
        | SOmNATH_pATRA | ACADEmiCS      | COmpUTER TEACHER | 2005-05-05    | RANCHi  | Emp05  |
        +---------------+----------------+------------------+---------------+---------+--------+
          1.9 oRDeR By coMManD

        Suppose  it  is  required  to  sort  the  result  of  a  query  based  on  some  attributes.  This  can  be  done  by  using  the
        clause – ORDER BY followed by the attributes which need to be sorted. For ascending order, the keyword ASC and for
        descending order the keyword DESC is used. By default, the order is ascending.
        Syntax:

        SELECT Column_Name FROm Table_Name
        WHERE [condition] ORDER By Column_name [ASC/DESC];
        Example:

        SELECT Emp_NAmE FROm EmpLOyEE_DETAiLS
        ORDER By Emp_iD;
        Output:
        +---------------+
        | Emp_NAmE      |
        +---------------+
        | NEHA_DAS      |
        | RADHA_SiNHA   |
        | RAVi_yADAV    |
        | SOmNATH_pATRA |
        | SOmNATH_pATRA |
        +---------------+
        Ð ÐFor Descending Order:
          SELECT Emp_NAmE FROm EmpLOyEE_DETAiLS
          ORDER By Emp_iD DESC;
        Output:
        +---------------+
        | Emp_NAmE      |
        +---------------+
        | SOmNATH_pATRA |
        | SOmNATH_pATRA |
        | RAVi_yADAV    |
        | RADHA_SiNHA   |
        | NEHA_DAS      |
        +---------------+
          1.10 gRoup By coMManD

        The GROUP BY statement groups rows that have the same values into summary rows, like find the number of customers
        in each country, Starting of specific Letter Name.
        Syntax:

        SELECT column1, function_name(column2) FROm table_name
        WHERE condition
        GROUp By column1, column2
        ORDER By column1, column2;



          174   Touchpad Information Technology-XII
   171   172   173   174   175   176   177   178   179   180   181