>Dear Experts
>
>Following are tow columns in Table1, Field1 has products and Fileld2 has quantity
>A-----------60
>A-----------45
>A-----------20
>B-----------40
>B-----------35
>B-----------85
>B-----------15
>C-----------12
>C-----------18
>
>In table I want to get sub totals of every category and then Grand Total at the end of the Table as below
>
>A-----------60
>A-----------45
>A-----------20
>sub total--125
>B-----------40
>B-----------35
>B-----------85
>B-----------15
>sub total--175
>C-----------12
>C-----------18
>sub total---30
>Grand total-330
>
>Please help
select cName, Qty from Table1 ;
union all ;
select padr("sub total",50) as cName, sum(qty) as Qty from table1 group by 1 ;
union all ;
select padr("Grand total",50) as cName, sum(gty) as Qty from table1 ;
into table tableNew
I'm not sure how to create the records in the right order, though.
If it's not broken, fix it until it is.
My Blog