I have to generate a report in Crystal report and VB report where database is Oracle, like the attached screen shot:
I have used the following query and got the output as below screen shot:
SELECT ins.ins, ins.ins_name, crdi.ct, crdi.bin,
(select count(*) from crdh where crd_st='CN') as CNcount, (select count(*)
from crdh where crd_st='PO') as POcount
FROM crdh, crdi, ins
where crdh.bn=crdi.bn and crdi.ins=ins.ins and crdh.crd_st IN ('PO','CN')
GROUP BY ins.ins, crdi.bn, ins.ins_name,crdi
ORDER BY ins.ins, crdi.bn;
I have the following issues:
- How can I correct the above query so that it can return the count of crd_st for a perticular bn where crd_st is 'CN' or 'PO' separately. For example this query should tell me what is the count of records where crd_st is PO for bn 123456.
- I am very new in the Crystal report. Please help to make this report file and
- Also tell me how can I implement Sr No for numbering of records in this report file(.rpt).
I ran the following query and got the output as below screen shot
SELECT ins.ins_name,ins.ins,
crdi.crd_st, crdi.bin, crdh.crd_st,
COUNT(crdh.crd_st) as count
FROM crdh, crdi, ins
WHERE crdh.crd_st IN ('PO','CN') and crdi.bn in
(select unique bn from crdh)and crdh.bn=crdi.bn and
crdi.ins=ins.ins
GROUP BY ins.ins, crdi.bn, ins.ins_name,
crdi.crd_st,crdh.crd_st
ORDER BY ins.ins, crdi.bn;
I want to show the count column as a row in the report for respective bn.
I have Oracle 10g database and followed the following link
link for pivote
And make the following query and got the 'ORA-00933: SQL command not properly ended' error.
SELECT bn, CNCount, POCount
FROM (
SELECT bn,
crd_st,
ROW_NUMBER() OVER (PARTITION BY bn ORDER BY crd_st) AS cardRank
FROM cardholder
)
pivot( count(crd_st) FOR cardRank IN ('CN' as CNCount, 'PO' as POCount));
Thanks for your help in advance.