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

  • Home
  • SEARCH
  • 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 8052099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:27:49+00:00 2026-06-05T07:27:49+00:00

I have 2 tables: money_change: id_change | id_factor | d_change | date ——————————————— 1

  • 0

I have 2 tables:

money_change:

id_change | id_factor | d_change | date
--------------------------------------------- 
1           5           0.10       2012-06-07
2           6           0.11       2012-06-07
3           5           0.12       2012-06-09
4           6           0.11       2012-06-10
5           8           1.09       2012-06-03  

money_factor:

id_factor | money_base | money_change
--------------------------------------
5           'Dollar'     'Yen' 
6           'Dollar'     'Euro'
7           'Euro'       'Dollar'
8           'Euro'       'Yen'

I’m trying to do a query that returns me the latest changes in currency to the dollar. I mean the result:

id_factor | d_change | date
--------------------------------------
5           0.12       2012-06-09
6           0.11       2012-06-10

I can know the last date for individual factor:

SELECT MAX( date )
FROM money_change
WHERE id_factor = 6

but as you might know the last date for each factor of “Dollar”? I tried something like this:

SELECT id_factor, d_change, date
FROM money_change c
INNER JOIN money_factor f
ON f.id_factor = c.id_factor
LEFT JOIN (
    SELECT MAX(date) AS date
    FROM money_change
) AS Last
ON c.dRegistro = Last.date
WHERE money_base = "Dollar"

but I returned:

id_factor | d_change | date
--------------------------------------
5           0.10       2012-06-07
6           0.11       2012-06-07
5           0.12       2012-06-09
6           0.11       2012-06-10

I think I need to enter the ‘where’ in the subquery, but as it dynamically for each factor?

  • 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-05T07:27:50+00:00Added an answer on June 5, 2026 at 7:27 am

    Try this query:

    SELECT
        t.id_factor,
        t.d_change,
        t.date
    FROM
    (
        SELECT
             mc.id_factor,
             mc.d_change,
             mc.date
        FROM
            money_change mc
        INNER JOIN
            money_factor mf USING(id_factor)
        WHERE
            mf.money_base = "Dollar"
        ORDER BY
            mc.date DESC
    ) t
    GROUP BY
        t.id_factor
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create 2 tables in Visual Studio server pane and I have
I have multiple tables that need to be merged into one. SELECT name, SUM(money)
I have tables: user, comment and post, say: A user can have many posts
I have tables: events -----+-------------------+ | id | eventName | -----+-------------------+ | 1 |
I have tables like this COUNT tbl id, userid, linkid, count 4 1 6
I have tables = expenses and invlines (invoice lines). Expense belongs_to Invline Invline has_many
I have tables like this: tblUsers int UserID string UserName tblUsersInRoles int UserID int
I have tables linked by FK, I query on the first table using entity
I have sales people and bean counters who are trying to sell customizations to
I have 2 different columns in 2 tables, one is with Money datatype in

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.