Just when you think your app is perfect, the people you wrote it for add another little qualifier. At current, the SQL query below pulls the required info for all records in the database, and orders them by ResearchID:
SQLStmt ="SELECT R.CreatedBy, R.ResearchID, R.AccountName, R.CurrentAccountNo, R.Status, R.RequestDate, R.DateAssigned, R.LocID, C.NickName + ' ' + C.LastName AS CreatedBy2, CASE (A.NickName + ' ' + A.LastName) WHEN ' ' THEN 'Unassigned' ELSE (A.NickName + ' ' + A.LastName) END AS AssignedTo FROM rrmain R INNER JOIN Employees C ON R.CreatedBy = C.EmployeeID LEFT OUTER JOIN Employees A ON R.AssignedTo = A.EmployeeID ORDER BY R.ResearchID"
This works peachy, however, now they want any research assigned to them specifically to appear at the top of the list for that person. The AssignedTo field has the number of the employee that is assigned to in it, BUT, this field can be null and will be until someone assigns it (Thus the part in the SQL query which decides if it's Unassigned or if it displays the name of the assignee). I could have it group by Assignees I think by adding R.AssignedTo to the ORDER BY, but that will group them asc or desc, not place the logged in Assignee's stuff at the top.
I am so lost on how to remedy this, it isn't even funny. Any and all help is much appreciated.
SQLStmt ="SELECT R.CreatedBy, R.ResearchID, R.AccountName, R.CurrentAccountNo, R.Status, R.RequestDate, R.DateAssigned, R.LocID, C.NickName + ' ' + C.LastName AS CreatedBy2, CASE (A.NickName + ' ' + A.LastName) WHEN ' ' THEN 'Unassigned' ELSE (A.NickName + ' ' + A.LastName) END AS AssignedTo FROM rrmain R INNER JOIN Employees C ON R.CreatedBy = C.EmployeeID LEFT OUTER JOIN Employees A ON R.AssignedTo = A.EmployeeID ORDER BY R.ResearchID"
This works peachy, however, now they want any research assigned to them specifically to appear at the top of the list for that person. The AssignedTo field has the number of the employee that is assigned to in it, BUT, this field can be null and will be until someone assigns it (Thus the part in the SQL query which decides if it's Unassigned or if it displays the name of the assignee). I could have it group by Assignees I think by adding R.AssignedTo to the ORDER BY, but that will group them asc or desc, not place the logged in Assignee's stuff at the top.
I am so lost on how to remedy this, it isn't even funny. Any and all help is much appreciated.