How to write different Query clauses in SQL Server ?

Leave a Comment
             There are many different query clauses in SQL Server. Much query run in SQL Server, Here I am writing some of Query and its result.

Distinct keyword
          When you need some data of table then you write this Query and get your result as shown below :
                          
We get following result :

Group by
          If you want to know name and total amount of salary on each teachers, then GROUP BY query would be as follows :
                                 
We get following result :


And / Or
                 AND and OR operators are used to combine multiple conditions to narrow data in an SQL statement. These two operators are called conjunctive operators. In AND operator two condition must be applied then we get result and In OR operator any of one condition applied then we get result.
                           
We get following result :
           

Top
          When we need some of top rows from table then we apply this Query.
                         
We get following result :

Like
          The Like Query clause is used to compare a value to similar value with use of wildcard operators. In below I shown you both of conjunction in one example. But you can used separately them.
                         
We get following result :

Order by
          When we need data to sort in aecending or descending order, then this type of query is used.
                         
We get following result :

Where
          This query used to specify a condition while fetching the data from table. We specify a condition using logical or comparision operator. For example  >,<,=,<=,>=,in,like,not, etc...
                         
We get following result :

0 comments:

Post a Comment