SELECT Emp1.LastName, Emp1.HireDate, (Select Count (*) from Employees Where [HireDate] < [Emp1].[HireDate])+1 AS Seniority FROM Employees AS Emp1 ORDER BY Emp1.HireDate;
what its doing is counting the number of records BEFORE the current record and then adding 1.
So you obviously need a unique field which you sort on.
I tabellen har jeg nogle deltagere, med nogle resultater, hvor der skal sorteres efter deres totalscore. Her kan flere deltagere godt have samme score, men i så fald skal der sorteres efter feltet G12. I dag ser min SQL således ud:
Select * from tblResultater order by total, g12, g11, g10, g9 osv. Her vil jeg bare erne have regnet placeringer ud, startende med 1 og så fortløbende nedad
Select * from tblResultater order by total, g12, g11, g10, g9 osv
so here you are just assuming that whoever got the best result in g12, from those having the highest total gets the best overall result no matter what their results were in g11, g10 osv?
easy enough to sort but not so easy to give a position.
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.