EXPERT RESPONSE
You may have to use the GROUP by function in your SQL statement.
I set up a table called SHELLYS_TABLE (sorry I spelled your name wrong) and inserted data in the table as follows.
If you want an output that will be something like the following for the company
ABC CO
SELECT issueto, MIR5P, status, SUM(indexpts), SUM(TOTALCREDIT)
FROM SHELLYS_TABLE
WHERE ISSUETO='ABC CO'
GROUP BY ISSUETO, MIR5P, STATUS
order by DECODE(MIR5P, NULL, '999999', MIR5P) DESC , STATUS DESC
/
If you want the counts of certain columns, say MIR5P and status then, you can use count function on these columns. For the second example I ran the query for the entire table, the query and its output is provided below:
SELECT issueto, MIR5P, status, count(MIR5P) CNT_M, count(status) CNT_S, SUM(indexpts) SUM_IDP, SUM(TOTALCREDIT), SUM_TC
FROM SHELLYS_TABLE
GROUP BY ISSUETO, MIR5P, STATUS
order by ISSUETO, DECODE(MIR5P, NULL, '999999', MIR5P) DESC , STATUS DESC
/
SELECT issueto, MIR5P, status, count(MIR5P), count(status), SUM(indexpts), SUM(TOTALCREDIT)
FROM SHELLYS_TABLE
WHERE ISSUETO='123 CO'
GROUP BY ISSUETO, MIR5P, STATUS
order by DECODE(MIR5P, NULL, '999999', MIR5P) DESC , STATUS DESC
/
|