Hello every one.
I have an SQL question a little bit tricky.
I have two tables with headers and lines linked by a FK in the line table. For example:
Header
PK_header
First_name
Last_name
...
and
Lines
PK_lines
FK_header
Item_number
Quantity
Price
I wish to format like this
PK_header First_name Last_name Item_number Quantity Price
1 fn1 ln1 123 1 12.99
345 2 4.99
789 1 5.49
2 fn2 ln2 159 1 2.99
753 2 1.49
3 fn3 ln3 675 1 0.99
...
The problem I have is not retrieving the information but formating them the way you can see above.
So how can write this in SQL for SQL Server?
I hope you see what I wish for. Thanks in advance for your help.
Yours,
Fred.
As asked:
Here is the query to retrieve informations I made:
select
header.PK, header.First_name, header.Last_name, ...
lines.Item_number, lines.Quantity, lines.price
from header
inner join lines
on header.PK = lines.PK_header
This query displays each header for each lines. I wish to display the header data only when the PK changes.
It's for SQL Server 2000 and it has to be in a stored procedure.