Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

What is SQL?

What is SQL?

SQL is a simple programming language designed for accessing and manipulating RDBMS databases (MS-SQL server, Oracle,   MySql etc).
SQL is ANSI (American national standards institute) standard language.
SQL stands for Structured Query Language.

There are 5 types of SQL statements

DRL (data retrieval language )
DDL(data definition language)
DML(data manipulation language)
DCL(data control language)
TCL(transaction control language)


SQL use:

The Data in RDBS (Relational Database Management System) is stored in objects called tables.

A table is a collection of related data entries and it consists of columns and rows.

1.  Using SQL you can create (ADD), DROP (Remove) table tables
2.   Using SQL you can create Database, Delete Database.
3.  Using SQL you can Insert, Update, and Delete data (records) in table, and these
4.  Operations also known as CRUD operation.
5.  SQL can create stored procedures in a database
6.  SQL can create views in a database
7.  SQL can set permissions on tables, procedures, and views


SELECT TITLE,Employee,[Description] from designation

Bootstrap code

Bootstrap code:

Bootstrap framework allows you to display code using two different tags:

1. Using pre tag

If the code needs to be displayed as a standalone block element or if it has multiple lines, then you should use the <pre> tag.

2. Using code tag

 If you are going to be displaying code inline, you should use the <code> tag.


With below example I want to display C# LINQ source code using bootstrap source and pre tag

<p>with &lt;pre&gt; tag code as: 
        <pre> var UserDetails = (from userData in DbContext.User where userData.ManagerId == 3
                                select userData).ToList();         
        <p>using code tag.</p>
      var UserDetails = (from userData in DbContext.User
                         where userData.ManagerId == 3
                         select userData).ToList();        

Output is:

Having Clause with CASE expression

Having Clause with CASE expression


My friend asked me a question, “Can I use case statement in a HAVING clause in SQL server?”

I was confused but still answered I think this is possible.

After some tweaks I crated t-sql query that uses case statement in having clause and that experience I shared in this tutorial.


In this example select statement returns employee with Searched CASE expression which satisfies following condition.


Male employee salary is more than “INR 150” per day and female employee salary is more than “INR 180.”

The searched CASE expression evaluates a set of Boolean expressions to determine the result.

Code Sample:

Employee table Data:



--- Searched CASE expression

SELECT EmployeeName ,Country,CompanyPlant,Gender, Total=MAX(PayScale)

FROM Employee

GROUP BY EmployeeName ,Country,CompanyPlant,Gender


 THEN PayScale

 ELSE NULL END) > 150.00

 OR MAX(CASE WHEN Gender = 'Female'

 THEN PayScale

 ELSE NULL END) > 180.00)


Select Query returned Data: