Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trouble with GROUP BY and ORDER BY
Message
De
28/04/2005 09:16:03
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01009167
Message ID:
01009199
Vues:
17
Here is the entire query:

SELECT jobinfo.ljob, COUNT(jobinfo.ljob) AS Weight, jobinfo.costdate, jobinfo.starttime,
CASE WHEN bbjthead.id = '' THEN '(No-ID)' ELSE bbjthead.id END AS ID FROM
(

SELECT ljob, costdate, starttime FROM bbjobcst
WHERE ljob <> ' ' AND ljob <> 'None ' AND costdate >= GETDATE() - 15 AND empno = @tcEmpno
--ORDER BY costdate desc, starttime desc

UNION ALL

SELECT ljob, costdate, starttime
FROM bbmatdc
WHERE ljob <> ' ' AND ljob <> 'None ' AND
costdate >= GETDATE() - 15 AND empno = @tcEmpno
--ORDER BY costdate desc, starttime desc

UNION ALL

SELECT ljob, costdate, starttime
FROM bbrolldc
WHERE ljob <> '' AND ljob <> 'None ' AND costdate >= GETDATE() - 15 AND empno = @tcEmpno
--ORDER BY costdate desc, starttime desc

)jobinfo
INNER JOIN BBJTHEAD ON BBJTHEAD.LJOB = jobinfo.ljob
GROUP BY jobinfo.ljob, BBJTHEAD.ID, jobinfo.costdate, jobinfo.starttime
ORDER BY jobinfo.costdate desc, jobinfo.starttime desc
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform