Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ordey By in Union

Status
Not open for further replies.

Arjan80

Programmer
Oct 17, 2001
3
NL
I made this sql:

select t.teamnaam, l.roepnaam
from team t left outer join lid l on t.trainer = l.l_code
where t.teamnaam like 'H%'
UNION
select '---------', ''
UNION
select 'Aantal teams', string(count(teamnaam))
from team where teamnaam like 'H%'
UNION
select 'Aantal teams met trainer', string(count(trainer))
from team where teamnaam like 'H%';

This is what I get:
__________________________________________________
Teamnaam | Roepnaam
Heren 2 |
Heren 3 |
Heren 4 |
Heren 5 |
----------------- |
Aantal teams met trainer | 1
Aantal teams | 5
Heren 1 | Kees
__________________________|_______________________

This is what I want to get:
__________________________________________________
Teamnaam | Roepnaam
Heren 1 | Kees
Heren 2 |
Heren 3 |
Heren 4 |
Heren 5 |
------------------ |
Aantal teams | 5
Aantal teams met trainer | 1
__________________________|_______________________


I have tried many ways of Order By, but I don't know how to do this,
Can anyone help?
Thank you,
Arjan - from Holland
 

Use UNION ALL rather than UNION.

select t.teamnaam, l.roepnaam
from team t left outer join lid l on t.trainer = l.l_code
where t.teamnaam like 'H%'
UNION ALL
select '---------', ''
.
.
. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top