Return multiple copies of same row in table with sequence number
Date: Fri, 7 Mar 2008 17:20:20 -0800 (PST)
Message-ID: <846bb9d5-846b-4ee2-9e37-4d873c40595f@v3g2000hsc.googlegroups.com>
I want to return multiple copies of data from a table but do not
understand how to accomplish this. The following code works to return
a fixed number of copies but I cannot determine how to replace the
constant with a variable. How do I do this and is there an easier
way?
I need to print numbered certificates for an employee. I can use the following sql to generate a fixed number of certificates but the number I need is in a field on the record.
select x.SeqNo,e.EmployeeNo,e.EmployeeName
from Employees e,
(select rownum SeqNo from dual connect by level <= 3) x
where e.EmployeeNo = 78
order by SeqNo
This returns:
1 78 Joe
2 78 Joe
3 78 Joe
What I need is:
select x.SeqNo,e.EmployeeNo,e.EmployeeName
from Employees e,
(select rownum SeqNo from dual connect by level <=
e.CertificateCount) x
where e.EmployeeNo = 78
order by SeqNo
However the above SQL returns ORA-00904: "H"."LICENSECOUNT": invalid identifier.
I have tried a number of other approaches but none have worked.
Thanks. Received on Fri Mar 07 2008 - 19:20:20 CST