Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
HiI have a table which has employees and their salaries and the year in a table.table salary(empId int,salaryYear int,salary int)i have a range table which is used to find out the different ranges of salaries.table range(rangeId int,rangePosition int,rangeStart int,rangeEnd int)which has values like 1 1 0 10001 2 1001 20001 3 2001 3000....i want to find out the number of employees in each salary range for a given year ? i cannot hardcode the ranges in the query . how do i do it ?thankskaushikEdited by - spock on 02/20/2002 00:55:43
byrmol
Shed Building SQL Farmer
1591 Posts
Posted - 2002-02-20 : 01:32:39
Spock,Something like...
Select Count(*) as Total, R.RangeStart, R.RangeEnd from Salary Sinner join Range R on S.Salary between R.RangeStart and RangeEnd group by R.RangeStart, R.RangeEnd
DavidMTomorrow is the same day as Today was the day before.Edited by - byrmol on 02/20/2002 01:33:18