Can you write an query for displaying employee name and salary status like salary greater than 20000 or less then 20000 (not display salary only these string according to their salary)?
Lets try
click here for read questpond article based on Case Syntax
@SortCoumn nvarchar(10)
as
Begin
Select [Id],[Name],[Gender],[Salary],[City]
From [Employee]
Order by Case When @SortCoumn = 'Id' Then Id End,
Case When @SortCoumn = 'Name' Then Name End,
Case When @SortCoumn = 'Gender' Then Gender End,
Case When @SortCoumn = 'Salary' Then Salary End,
Case When @SortCoumn = 'City' Then City End
End
Lets try
Here we will use the Case Syntax
I have written this article after reading Questpond article click here for read questpond article based on Case Syntax
other case example
Create Proc spGetEmployeesSorted@SortCoumn nvarchar(10)
as
Begin
Select [Id],[Name],[Gender],[Salary],[City]
From [Employee]
Order by Case When @SortCoumn = 'Id' Then Id End,
Case When @SortCoumn = 'Name' Then Name End,
Case When @SortCoumn = 'Gender' Then Gender End,
Case When @SortCoumn = 'Salary' Then Salary End,
Case When @SortCoumn = 'City' Then City End
End
No comments:
Post a Comment