Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Selected fixed amount of rows

Author  Topic 

jgandara
Starting Member

18 Posts

Posted - 2005-03-14 : 14:01:07
I have to print an invoice and I need to select 12 rows at a time. So if the original invoice has 3 rows of detail, I need to have 9 more of empty values. For example:

Desc Qty Amt
Detail1 2 3
Detail2 1 5
<PaddedRow> 0 0
<PaddedRow> 0 0
....
12 in total.

I'm creating the invoice in crystal reports and I don't see a way to do it there. I'm connecting to an iSeries database, so I can't use store procedures, just plain SQL.

Thank you

Kristen
Test

22859 Posts

Posted - 2005-03-14 : 14:36:01
Can you use a UNION?

SET ROWCOUNT 12
SELECT Desc, Qty, Amt
FROM MyTable
WHERE InvoiceID = 1234
UNION ALL
SELECT NULL, NULL, NULL
ORDER BY CASE WHEN Desc IS NOT NULL THEN 1 ELSE 2 END
SET ROWCOUNT 0

Kristen
Go to Top of Page
   

- Advertisement -