You are not logged in Log in Join
You are here: Home » Members » MJ's corner on Zope » QuantumPythons » Question9

Log in
Name

Password

 
 
FrontPage »

Question9

Question 9

Create a view, ORD_Total that give the ordno, cid, aid, month, and total which is the sum of the dollars for any given order. Issue the query SELECT * FROM ORD_Total;

SQL:

    create view ord_total
        as select ordno,cid,aid,month, sum(dollars) as Total
        from ord_order_line
        group by ordno,cid,aid,month;.

Output:

    ORDNO CID  AID MONTH TOTAL                            
    ----- ---- --- ----- ---------------------------------
    1011  c001 a01 jan   2850.00
    1012  c001 a01 jan    450.00
    1013  c002 a03 jan    880.00
    1014  c003 a03 jan   1104.00
    1015  c003 a03 jan   1104.00
    1016  c006 a01 jan    500.00
    1017  c001 a06 feb    540.50
    1018  c001 a03 feb   1860.00
    1019  c001 a02 feb    900.00
    1020  c006 a03 feb    600.00
    1021  c004 a06 feb   1160.00
    1022  c001 a05 mar   1920.00
    1023  c001 a04 mar    450.00
    1024  c006 a06 mar    400.00
    1025  c001 a05 apr    720.00
    1026  c002 a05 may    704.00
    1035  c006 a06 may    725.55
    1036  c006 a06 may    400.55
    1050  c006 a01 may      0.50

  1. record(s) selected. .


john_knight (Sep 15, 2001 6:17 pm; Comment #1)
JAK's 3rd Q
mj (Sep 15, 2001 11:04 pm; Comment #2)
Wow, this is exactly the same question as problem number 2 in seminar 4..