SQLite Forum

ORDER BY not ordering with the correct result
Login
Greetings.

I have this SQL code,

```
WITH ProjIDs AS (VALUES 
   ('PR0000016675'),
   ('PR0000017285'),
   ('PR0000017416'),
   ('PR0000019109'),
   ('PR0000019129'),
   ('PR0000019130'),
   ('PR0000019131'),
   ('PR0000019133'),
   ('PR0000019135'),
   ('PR0000019136'),
   ('PR0000019139'),
   ('PR0000019140'),
   ('PR0000019141'),
   ('PR0000019142'),
   ('PR0000019143'),
   ('PR0000019147'),
   ('PR0000019148'),
   ('PR0000019150'),
   ('PR0000019152'),
   ('PR0000019164'),
   ('PR0000019176'),
   ('PR0000019180'),
   ('PR0000019186'),
   ('PR0000019191'),
   ('PR0000019764')
)
SELECT a.*,total(b.AnnualDossier) as Dossier FROM Project_List AS a 
LEFT JOIN ABT_Budget AS b ON a.ProjID = b.ProjID 
AND b.InsertDate = 
  ( 
     SELECT MAX(InsertDate) FROM ABT_Budget WHERE b.ProjID IN ProjIDs 
     OR 
     b.InsertDate IS NULL 
  ) 
WHERE a.ProjID IN ProjIDs 
AND a.InsertDate = 
( 
   SELECT MAX(InsertDate) FROM Project_List WHERE ProjID = a.ProjID  
) 

  GROUP BY a.ProjID
  ORDER BY a.Project_Manager;
```

But I am not getting a sorted by Project_Manager. What am I doing wrong? Thanks for the support.

josé