Re: sql select
Posted in 1998
Hello Syed. You can do the following: 1) unload to "oper.unl" delimiter "|" select month(trans_date), sum(inflow), sum(outflow), sum(inflow) - sum(outflow) from your_table group by 1 order by 1 You will get the file oper.unl as following: 1|7000|3000|4000| 2|5000|1000|4000| 3|4000|3000|1000| 2) Use awk to format the output. Or you can write a program in 4GL etc. to create the report. Hope this helps. Regards. Alexander Leites Syed <sas@mastic.gov.my> '''''''' ' '''''' <6so9al$d23$1@news.xmission.com>... > > Dear friends, > > How do I make two columns in my table to be two rows in my report? for > example, I have a table called cash flow and its structure is like this > > DATE CASH INFLOW CASH OUTFLOW > ---- ----------- ------------ > 1/1/98 4,000 2,000 > 2/1/98 3,000 1,000 > 1/2/98 5,000 1,000 > 1/3/98 4,000 3,000 > > I want to produce a report like this > > Type 1/98 2/98 3/98 > ---- ----- ----- ----- > a)CASH INFLOW 7,000 5,000 4,000 > b)CASH OUTFLOW 3,000 1,000 3,000 > ------------------------------------- > NET FLOW(a-b) 4,000 4,000 1,000 > ------------------------------------- > > I am not good at sql, however I am sure sql can do this. > > Syed. > > > -- > Syed Ibrahim > Sapura Advanced Systems Sdn. Bhd, 18th Floor, Menara Tun Razak, Jalan > Raja Laut, 50350 Kuala Lumpur, Malaysia > Tel: (03) 295-3472, (03) 294-3000 Fax: (03) 294-6587, (03) 293-3154 >