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 7833347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:39:58+00:00 2026-06-02T12:39:58+00:00

I have two tables which looks as below First table : DealNum CurrencyValue CurrencyCode

  • 0

I have two tables which looks as below

First table :

   DealNum      CurrencyValue      CurrencyCode       Date

    110             100                 AA         01/12/2011  
    111             200                 AB         01/11/2011
    112             120                 AC         01/10/2011  
    113             20                  AA         01/11/2011
    110             103                 AD         01/12/2011  
    115             200                 AD         01/11/2011
    119             120                 AG         01/10/2011  
    130             20                  AK         01/11/2011

Second Table

   CurrencyCode     OCT       NOV      DEC     JAN   ..

      AA             0.91     0.88     0.9     0.94  
      AB             0.9      0.8      0.96    0.89
      AC             0.81     0.79     0.82    0.84  
      AD             0.4      0.41     0.42    0.39
      AE             0.9      0.92     0.91    0.94  
      AF             0.8      0.82     0.83    0.81

now I want to add the data from the second table to first table in a new column with the following conditions

1.It has to do based on the CurrencyCode and month
2.If the deal is from DEC and currencyCode is AA , then it has to take the value 0.9,
  if the deal is from NOV and currencyCode is AA , then it has to take the value 0.88..

So, The result should look like this

   DealNum      CurrencyValue      CurrencyCode       Date        NewColumn

    110             100                 AA         01/12/2011        0.9
    111             200                 AB         01/11/2011        0.8
    112             120                 AC         01/10/2011        0.81  
    113             20                  AA         01/11/2011        0.88
    110             103                 AD         01/12/2011        0.42
    115             200                 AD         01/11/2011        0.41
    119             120                 AG         01/10/2011         --
    130             20                  AK         01/11/2011         --

I have no clue on how to do this with comparing row value of month from first table to column value of month in second table. Please help me with this..

Thanks in advance.

Cheers,
Harish.

  • 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-02T12:40:04+00:00Added an answer on June 2, 2026 at 12:40 pm

    This should work, although you second table is not designed well.

    SELECT   DealNum      
           , CurrencyValue      
           , CurrencyCode       
           , Date
           , Deal = 
             CASE MONTH(t1.Date)
               WHEN 1 THEN t2.JAN
               WHEN 2 THEN t2.FEB
               WHEN 3 THEN t2.MAR
               -- .....
               WHEN 10 THEN t2.OCT
               WHEN 11 THEN t2.NOV
               WHEN 12 THEN t2.DEC
            END
    FROM Table1 t1 
    INNER JOIN Table2 t2 ON t1.CurrencyCode = t2.CurrencyCode 
    
    • MONTH
    • CASE
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables which looks something like this Table Queue int ID; string
I have two tables which look like this: T1: T1ID | Date | Time
I have two tables which looks like this: News: (ID, Title, TagID) Tags: (ID,
I have two tables in my database: test1 which looks like: ID pubmed_ID -------------------
I have two simple tables in Django which looks like: class Session(models.Model): id =
I have two tables TABLE1 which looks like: id name address 1 mm 123
I have two tables which are used to store details of different types of
I have two tables which I want to join together using a left outer
I have two tables which have some transactional stuff stored in them. There will
I use Hibernate with Java. I have two tables which are associated with foreign

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.