Monday, 30 July 2012

SQL Query: UNION Query Example - Yes No

Scenario:
User should have option New Students Only? DropDownList: Yes, No. We have a table from where we know only starting admission number of new students.

Solution:
Say for example: New students starting admission number is 26500 that means all the new student's admission number will be greater than 26500, old student admission could be anything greater than 0.

SELECT        'Yes' AS Response, StartStudentID
FROM            vwPortalYear

UNION

SELECT        'No' AS Response, 0 AS StartStudentID

Here, Response and StartStudentID is column name. Yes, 26500 and No, 0 are the two record.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home