I have what seems to be a strange results order question.Using the following test table and query;declare @TestTable table (ID int,ProjectId int,HoursEntered decimal (18,2))insert into @TestTable(ID,ProjectId,HoursEntered)values (1, 5, 5.0),(2, 2, 2.0),(3, 5, 2.0),(4, 4, 1.0),(5, 2, 3.0)SELECT T.ID, T.ProjectId, T.HoursEnteredFROM @TestTable TORDER BY ProjectId
The folowwing results are returned:ID ProjectId HoursEntered2 2 2.005 2 3.004 4 1.001 5 5.003 5 2.00
However, I need the results to be returned like so:ID ProjectId HoursEntered1 5 5.003 5 2.002 2 2.005 2 3.004 4 1.00
The ProjectId's need to be listed together, but the ID needs to be ascending as much as the projectId allows. How can the query be written so the data is returned like that?Are there any tricks using the Order By clause possibly?Thanks.