Results 1 to 6 of 6

Thread: How can I make a group amount/ total amount recordset ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    111

    How can I make a group amount/ total amount recordset ?

    Hello,
    If I have a table have (id, amount) and id can be duplicate. How can I make a recordset having id,amount, amount percentage where amount percentage is group amount/ total amount. How can I make a recordset like this ?

  2. #2

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    111

    Re: How can I make a group amount/ total amount recordset ?

    select id, sum(amount) , percentage(groupsum/total) from XXXX group by id

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How can I make a group amount/ total amount recordset ?

    More of an SQL/database question. Moved to database section.

  5. #5
    Fanatic Member vb_dba's Avatar
    Join Date
    Jun 2001
    Location
    Somewhere aloft between the real world and insanity
    Posts
    1,016

    Re: How can I make a group amount/ total amount recordset ?

    What type of RDMS are you using (Access, SQL Server, Oracle, etc)?
    Chris

    Master Of My Domain
    Got A Question? Look Here First

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How can I make a group amount/ total amount recordset ?

    Potentially something like this, if the DBMS supports subqueries in the Select clause:
    Code:
    select id, sum(amount) , (sum(amount) /  (select sum(amount) from XXXX))*100 from XXXX group by id

Posting Permissions

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



Click Here to Expand Forum to Full Width