SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2002
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is GROUP BY the answer?

    I have a transaction table that looks like this:

    TransTypeID TransNo TransDesc Amount
    6 4550 1 Year Membership $20
    6 4550 Info Book1 $0
    6 4550 Postage $5
    3 4550 Payment $25
    6 4551 2 Year Membership $30
    6 4551 Info Book3 $0
    6 4551 Postage $5
    3 4551 Payment $35

    and I need to display it in a report like this

    TransNo TransDesc Amount
    4550 1 Year Membership; Info Book 1 $25
    4551 2 Year Membership; Info Book 3 $35

    how do I write the WHERE statement, and do I need to use GROUP BY TransNO??

    Any help would be appreciated.
    ciao
    Xhosa

  2. #2
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mmmm I think your transaction database should entend a little bit
    I would have 2 table to keep things at hand
    Item table
    4550 1 Year Membership

    Features table
    4550 Base price $20
    4550 Postage $5


    But lets come to your problem
    Select TransNo, TransDesc, sum(amount) amnt from transaction where TransTypeID= 6 GROUP BY TransNo


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •