可能需要用到cursor,但又是掌握的不够透彻,悲剧啊。所以还请大家能够帮帮忙,看看这个语句怎么写,个人感觉有点复杂,要用嵌套循环来产生每个单独客户的账户订单。先有3个数据表
1. charges 表 
  Purchase A/C Product        Purchase
    Number No.  Code      Qty   Date
---------- --- ------- ------ ---------
       101 12  H123         3 04-JUN-09
       102 12  P227         1 04-JUN-09
       103 12  B127         5 04-JUN-09
       104 12  B010         4 04-JUN-09
       105 16  P227         2 04-JUN-09
       106 17  C129         5 04-JUN-09
       107 17  H140         1 04-JUN-092. account表
ID NAME                 STREET               SUBURB          POST PHONE
-- -------------------- -------------------- --------------- ---- ---------------
12 Smyth, R             2a Low Rd            Lawnceston      7250 6412 3456
15 Jonas, S             45 Upper Main St     Hoburt          7009 0417 123 456
16 Weston, J. K.        32 Marine Parade     Burney          7418 6422 1234
17 Chen-Smith, Z.       Back St              Knewnham        7251 0418 592 123
19 Zhou, J.             26 Beauty View       Sandie Bay      7002 6422 4321
21 Smyth-Jones, S.      1 Lower Main Road    Andtherest      7253 0418 592 3213.product表
CODE DESCRIPTION                    STOCK_ON_HAND REORDER_LEVEL  MAX_STOCK COST_PRICE SELLING_PRICE G
---- ------------------------------ ------------- ------------- ---------- ---------- ------------- -
H123 Fuse Wire                                 17            15         25        1.5          2.95 G
H124 Knife                                     11            10         20        8.5         14.95 G
B126 Pineapple                                 11            10         15        2.5          4.95 P
B127 Bread (White) - 1kg                       77            75        100        1.5          4.95 P
B136 Baked Beans - 500g                        27            20         35        2.5          5.95 N
B147 Chocolate Bar - 150g                     102           100        150       1.75          2.95 N
C129 Coca Cola - 375ml                        253           250        400       1.95          2.95 N
C140 Coca Cola - 1 ltr                         60            50         75        2.5          3.75 N
P227 Hair Brush                                14            12         15        5.5         10.95 G
H129 Tap washer                                14             5         20        .75          1.25 G
H120 Torch Battery - 6v                         3             2          4        4.5           8.5 G
P130 Razor                                     10             5         20        5.5          7.45 G
H140 Shoe Polish (Black) - 20g                  5             4         10        4.5          9.95 G
B010 Bread (White) - 500g                      88            75        100       1.25           2.8 P
B020 Bread (Multi grain) - 1 kg                79            75        100        2.5             5 P
B030 Hamburger Meat - 250g                     32            30         60        3.5          4.95 P
B040 Hamburger Bun                             41            30         60        .65           .95 P
C010 Coca Cola - 2.5 ltr                      270           250        400        3.5          4.95 N
C020 Diet Coca Cola - 500 ml                   83            50         75        1.9          2.95 N题目要求不绕,要求列出每个客户(包括未购物)的购物信息
结果有example
             tatement Dated : 16/MAY/09
             Account Number : 12
  Smyth, R,
  2a Low Rd,
  Lawnceston,
  Tasmania,7250.-------  ------------   ---  -----  --------
Product  Description    Qty   Unit  Extended
 Code                        Price    Price
-------  ------------   ---  -----  --------H123     Fuse Wire       3    2.95    8.85
P227     Hair Brush      1    10.95   10.95
B127     Bread (White)   5    4.95    24.75
                                     =======
                              TOTAL   44.55
                                     =======
表头居中显示日期,换行显示订单号
显示客户信息
接着就是具体显示订单的信息了,包括产品code,description,qty,单价,总价
还得用computer 计算一下所有商品总价。格式化这一块显示的时候有的问题,自己想的有些乱了,能帮忙做下的真是感激不尽了,谢谢大家。