Steps to Customize the Result Set with Example: SQL Programming

January 10, 2014 , 0 Comments

SQL Server management studio needs to connect to a server to perform any query with it. The article will describe about to customize the result set using sql programming.

The management at Adventure Works. Inc. wants to view a report that displays the employee ID, designation, and age of the employees who are working as a marketing manager or a marketing specialist. The data should be displayed in uppercase. The employee details are stored in the Employee table in the Adventure Works database.

To solve the problem, programmer need to perform the following tasks:

Creating a Query

To display the age of the employees, you need to use the datediff function to calculate the difference between their birth date and the current date. In addition, to retrieve the data for a marketing manager or a marketing specialist, you need to use the OR logical operator.

Type the following query in the Query Editor window of the Microsoft SQL Server Management Studio window:

SELECT BusinessEntityID, upper (JobTitle) As
Designation,datediff (yy, Birthdate, getdate ( )) As Age
FROM HumanResources.Employee WHERE JobTitle='Marketing Manager'
OR JobTitle ='Marketing Specialist'

Executing the Query to Display Data

Press the F5 key or click the Execute button to execute the query and view the result set. The following figure displays the output.

Steps to Customize the Result Set with Example: SQL Programming

Rhett Butler

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google