Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8072907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:10:28+00:00 2026-06-05T14:10:28+00:00

I have two tables, one with transactions (with date). The other with a percentage

  • 0

I have two tables, one with transactions (with date). The other with a percentage and date the percentage it went into effect (assume 00:00:00). The percentage remains in effect until a new percent goes into effect. I need to join on the percentage that was in effect when the transaction happened.

transactions_table

event_date     amount
2011-01-01     230
2011-02-18     194
2011-03-22     56
2011-04-30     874

percent_table

effective     percent
2010-12-30    15
2011-03-05    25
2011-04-12    30

The result I’m looking for is:

event_date     amount     percent
2011-01-01     230        15
2011-02-18     194        15
2011-03-22     56         25
2011-04-30     874        30

I’ve tried:

SELECT t.event_date, t.amount, p.percent 
FROM transactions_table AS t 
LEFT JOIN percent_table AS p ON t.event_date >= p.effective 
ORDER BY `t`.`event_date` DESC LIMIT 0 , 30;

That gives me, seemingly random percentages. It seems to me like I need to get the greatest date >= p.effective, not just any random date >= p.effective.

I tried:

SELECT t.event_date, p.percent 
FROM bedic_sixsummits_transactions AS t 
LEFT JOIN bedic_sixsummits_percent AS p ON MAX(t.event_date >= p.effective) 
ORDER BY `t`.`event_date` DESC LIMIT 0 , 30

but MySQL just laughed at my feeble attempt.

How can I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:10:30+00:00Added an answer on June 5, 2026 at 2:10 pm
    SELECT t.event_date, t.amount, p.percent
    FROM bedic_sixsummits_transactions AS t
    LEFT JOIN bedic_sixsummits_percent AS p
    ON p.effective = 
       ( SELECT MAX( p2.effective ) FROM bedic_sixsummits_percent AS p2
         WHERE p2.effective <= t.event_date
       )
    ORDER BY t.event_date DESC LIMIT 0 , 30
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables in my database, one is Transactions and the other is
I have two tables one called fs_note the other called dumy_fs_note I created after
I have two tables : one table it matchs and the other is teams.
I have two tables, one that has 450 rows, the other is a Sort
Lets say I have two tables, one for transactions, and another table who's primary
I have two tables: one contains employees information and another is transactions (sales) information
This is the situation: I have two tables where the one references the other
I have two tables, one table A that is the parent and other table
I have two tables one with ID and NAME table 1 ID | NAME
i have two tables one is called addons and holds information about different addons,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.