Labels

Wednesday, 23 December 2015

SQL Server - Compute ..By


Compute..By

                In general we are not allowed to use group or aggregate functions after table name except                     with having clause .
                By using this clause you can perform group or aggregate functions after table name .

Ex:

                * Select * from emp compute min(start_date)
                * Select * from emp order by region compute min(hire_date) by job
                * select * from emp compute sum(sal),avg(sal),min(sal)

Notes
                The data within anglerbrackets(<>) is compulsory , where as in square brackets [] is optional in database sub-language

                The query execution order is  FROM-->T.N-->*-->WHERE

                The Precedence of clauses is  Top > Group By> having > Order By > Compute By


1 comment:

  1. Thanks for posting this option . It is very useful and time saving option with minimal code.

    ReplyDelete