Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Union order
Message
De
29/08/2008 15:10:56
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Union order
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01343299
Message ID:
01343299
Vues:
61
I've got a select statement that I'm unioning and my results come back with the second select statements data in the first row and the first selects data in the second row.

Here's the statement:
SET @cJobNo = '11708'

SELECT TimeHD.Empid, TimeHD.EmpName,
	sum(regtime) as RegTime,sum(overtime) as OverTime, Sum(doubletime) as DoubleTime,
	sum(regtime+overtime+doubletime) as TotalHours1
FROM TimeHd INNER JOIN
	TimeItms ON TimeHd.timecrdno = TimeItms.timecrdno
Where TimeItms.JobNo = @cJobNo and
	TimeItms.[distributed] <> 1

group by TimeHD.Empid, TimeHD.EmpName

UNION ALL

SELECT TimeHD.Empid, TimeHD.EmpName,
	sum(regtime) as RegTime,sum(overtime) as OverTime, Sum(doubletime) as DoubleTime,
	sum(regtime+overtime+doubletime) as TotalHours1
FROM TimeHd INNER JOIN
	TimeItms ON TimeHd.timecrdno = TimeItms.timecrdno
Where TimeItms.JobNo = @cJobNo and
	TimeItms.[distributed] = 1

group by TimeHD.Empid, TimeHD.EmpName

order by empid
I've tried switching the where clauses around but it doesn't seem to matter. Any ideas?
Thanks
Jon
Non-MVP Non-MCP Non-MCSE

Visual FoxPro, What else is there?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform