How to JOIN with missing rows? Announcing the arrival of Valued Associate #679: Cesar Manara ...

If Windows 7 doesn't support WSL, then what does Linux subsystem option mean?

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

How do living politicians protect their readily obtainable signatures from misuse?

How much damage would a cupful of neutron star matter do to the Earth?

Is there any word for a place full of confusion?

How were pictures turned from film to a big picture in a picture frame before digital scanning?

Would it be easier to apply for a UK visa if there is a host family to sponsor for you in going there?

How does the math work when buying airline miles?

Converted a Scalar function to a TVF function for parallel execution-Still running in Serial mode

Is there a kind of relay that only consumes power when switching?

What do you call the main part of a joke?

Do wooden building fires get hotter than 600°C?

Should there be a hyphen in the construction "IT affin"?

Strange behavior of Object.defineProperty() in JavaScript

Sentence order: Where to put もう

How to improve on this Stylesheet Manipulation for Message Styling

Importance of からだ in this sentence

Quadrilaterals with equal sides

What would you call this weird metallic apparatus that allows you to lift people?

Why do early math courses focus on the cross sections of a cone and not on other 3D objects?

QGIS virtual layer functionality does not seem to support memory layers

A term for a woman complaining about things/begging in a cute/childish way

Why limits give us the exact value of the slope of the tangent line?

Did Mueller's report provide an evidentiary basis for the claim of Russian govt election interference via social media?



How to JOIN with missing rows?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)How to JOIN two table to get missing rows in the second tableMissing values in INNER JOIN MS-Access?Expressing some queries without employing JOIN or OUTER JOINMysql JOIN with 25million rowsMissing entries in joinJOIN and GROUP BY with additional columnsSpeed up SELECT query with JOIN from table with 2.2M rows in PostgreSQL?How to UPDATE from JOIN with GROUP BYHow to do a Join with optionally matching columnsHow to show missing rows with default values





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I need to JOIN two tables to correct the price with exchange rates as



SELECT date, price/rate AS adjusted FROM
table1 a JOIN table2 b ON a.date=b.date


The problem is that table2 does not have the exchange rate for all dates.



How can I get a nearest exchange rate for missing dates in table2?



EXAMPLE



Table 1



date          price
2019-01-01 2.3
2019-01-03 3.4
2019-01-04 2.6
2019-01-05 2.2
2019-01-06 2.5
2019-01-07 5.1
2019-01-08 4.6
2019-01-09 4.2
2019-01-10 3.3


Table 2



date          rate
2019-01-04 1.1
2019-01-06 1.3
2019-01-09 1.0


Alternatively, an approach to fill the missing dates in table2 works too.









share





























    0















    I need to JOIN two tables to correct the price with exchange rates as



    SELECT date, price/rate AS adjusted FROM
    table1 a JOIN table2 b ON a.date=b.date


    The problem is that table2 does not have the exchange rate for all dates.



    How can I get a nearest exchange rate for missing dates in table2?



    EXAMPLE



    Table 1



    date          price
    2019-01-01 2.3
    2019-01-03 3.4
    2019-01-04 2.6
    2019-01-05 2.2
    2019-01-06 2.5
    2019-01-07 5.1
    2019-01-08 4.6
    2019-01-09 4.2
    2019-01-10 3.3


    Table 2



    date          rate
    2019-01-04 1.1
    2019-01-06 1.3
    2019-01-09 1.0


    Alternatively, an approach to fill the missing dates in table2 works too.









    share

























      0












      0








      0








      I need to JOIN two tables to correct the price with exchange rates as



      SELECT date, price/rate AS adjusted FROM
      table1 a JOIN table2 b ON a.date=b.date


      The problem is that table2 does not have the exchange rate for all dates.



      How can I get a nearest exchange rate for missing dates in table2?



      EXAMPLE



      Table 1



      date          price
      2019-01-01 2.3
      2019-01-03 3.4
      2019-01-04 2.6
      2019-01-05 2.2
      2019-01-06 2.5
      2019-01-07 5.1
      2019-01-08 4.6
      2019-01-09 4.2
      2019-01-10 3.3


      Table 2



      date          rate
      2019-01-04 1.1
      2019-01-06 1.3
      2019-01-09 1.0


      Alternatively, an approach to fill the missing dates in table2 works too.









      share














      I need to JOIN two tables to correct the price with exchange rates as



      SELECT date, price/rate AS adjusted FROM
      table1 a JOIN table2 b ON a.date=b.date


      The problem is that table2 does not have the exchange rate for all dates.



      How can I get a nearest exchange rate for missing dates in table2?



      EXAMPLE



      Table 1



      date          price
      2019-01-01 2.3
      2019-01-03 3.4
      2019-01-04 2.6
      2019-01-05 2.2
      2019-01-06 2.5
      2019-01-07 5.1
      2019-01-08 4.6
      2019-01-09 4.2
      2019-01-10 3.3


      Table 2



      date          rate
      2019-01-04 1.1
      2019-01-06 1.3
      2019-01-09 1.0


      Alternatively, an approach to fill the missing dates in table2 works too.







      mysql join query





      share












      share










      share



      share










      asked 56 secs ago









      GooglebotGooglebot

      1,570174368




      1,570174368






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "182"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f235273%2fhow-to-join-with-missing-rows%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f235273%2fhow-to-join-with-missing-rows%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          ORA-01691 (unable to extend lob segment) even though my tablespace has AUTOEXTEND onORA-01692: unable to...

          Always On Availability groups resolving state after failover - Remote harden of transaction...

          Circunscripción electoral de Guipúzcoa Referencias Menú de navegaciónLas claves del sistema electoral en...