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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:44:31+00:00 2026-06-13T06:44:31+00:00

Given two tables like this: Date | Client | Category | Amount1 | x

  • 0

Given two tables like this:

Date | Client | Category | Amount1 | x
A      B        C          234
X      Y        Z          456

MonthDate | Client | Category | Amount2 | y
B           C        D          567
A           B        C          123

How can I find records where x.Month(Date) = y.MonthDate, x.Client = y.Client, and x.Category = y.Category?

I need to be able to display Amount1 – Amount 2 = Net for certain clients.

  • 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-13T06:44:32+00:00Added an answer on June 13, 2026 at 6:44 am

    A direct interpretation

    SELECT x.Date, y.MonthDate, X.Client, Y.Category, X.Amount1 - Y.Amount2 Nett
    FROM TBL1 X
    JOIN TBL2 Y ON Month(x.Date) = y.MonthDate
               AND x.Client = y.Client
               AND x.Category = y.Category
    

    However, if one of them is a monthly invoice and the other raw records, then you could be after an aggregate:

    SELECT y.MonthDate, Y.Client, Y.Category, ISNULL(SUM(X.Amount1),0) - Y.Amount2 Nett
    FROM TBL1 X
    RIGHT JOIN TBL2 Y ON Month(x.Date) = y.MonthDate
               AND x.Client = y.Client
               AND x.Category = y.Category
    GROUP BY y.MonthDate, Y.Client, Y.Category, Y.Amount2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem Given the following two tables, I'd like to select all Ids for Posts
I have two tables in a teradata database that look like this accounts account_number
I have two tables in my database that look like this CREATE TABLE IF
I have two tables that look like this Train +----------+-------------+------+-----+---------+-------+ | Field | Type
I have two tables one Employee and mailing Subscriptions Employee looks like this: Name
Given two tables APPLE and ORANGE, NAME APPLES Alice 5 Bob 10 Trudy 1
given the two tables and values: Tables People- Columns: [ID]PK Name Field - Columns:
Given a database with two tables X and Y , I have a query
I need to perform data validation of two tables using Selenium . Given a
I have 10 tables in my database(MySQL). two of them is given below tbl_state

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.