Skip to content
Advertisement

How to have data in Range column

I have 1 table named Temp1 and Columns are as below. In this table we have to make sure that salary of employee for any designation must be in between TopRange and Bottom Range. So I need to create a column combining 2 column Salary Top Range and Salary Bottom range

Sample data:

I want to create a column Range with a value of 3000-15000. Is that possible in SQL Server?

Advertisement

Answer

You can add a computed column:

This column will be calculated when you query it, so it will always be up-to-date.

Note that range is a SQL keyword, so I renamed it to salary_range. As a keyword, it is used in defining the window frame for a window function.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement