×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Group Record...

Group Record...

Group Record...

(OP)
How would I do I group my records into one record for each month?

SELECT Montly_Rpt_Table.REPID, Montly_Rpt_Table.Rep, Montly_Rpt_Table.MonthAbb, Montly_Rpt_Table.LostAmt, Montly_Rpt_Table.WonAmt
FROM Montly_Rpt_Table
WHERE (((Montly_Rpt_Table.REPID)=2));


REPID REP MonthAbb LostAmt WonAmt
2 MIKE JAN $15,000
2 MIKE JAN $7,000
2 MIKE FEB $1,500
2 MIKE FEB &1,200

RE: Group Record...

Hi tamer64,
Please use the TGML tags to format your posts so they can be more easily read. We can't tell if there are numbers in one or the other column. Then always Preview the message prior to posting.

It would also help if you posted what you want your results to look like so we can understand your requirements.

REPID  REP     MonthAbb LostAmt WonAmt
2      MIKE    JAN     $15,000
2      MIKE    JAN     $7,000
2      MIKE    FEB     $1,500
2      MIKE    FEB     $1,200 

We don't know what you want to do the the Rep fields and if you are summing or returning the max, min, or average of the amount columns.

I expect you could group by the MonthAbb column and Sum() the amounts.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

RE: Group Record...

(OP)
Thanks for the tip, but I tried using the TGML tags and I made sure it was checked and it doesn't seem I can get this to format correctly.

I don't need to sum any totals. The second record for "MIKE" the amount $7,000 is actually a WonAmt and that goes the same for the last record in the WonAmt of $1,200. The output should only be two records. One record for Jan with a LostAmt and WonAmt on the same row for Mike.

I hope this makes some sense.
bigsmile

RE: Group Record...

Using TGML is like formatting in Word. You select the text and click the appropriate tag/icon.
Try:

CODE --> SQL

SELECT REPID, REP, MonthABB, Sum(LostAmt) as Lost, Sum(WonAmt) As Won
FROM Montly_Rpt_Table
WHERE REPID=2
GROUP BY REPID, REP, MonthABB; 

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

RE: Group Record...

(OP)
Thank You that worked perfectly!!bigsmile

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close