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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:19:08+00:00 2026-06-12T14:19:08+00:00

I have 2 tables that have similar data and I need to compare the

  • 0

I have 2 tables that have similar data and I need to compare the values of one table with the other where the dates are equal.

Example tables:

CREATE TABLE [data].[ProfileReconciliation] (
[ProfileName] varchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[OriginalFeedDate] datetime NOT NULL ,
[AggregationDate] datetime NOT NULL ,
[TotalDescription] varchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[TotalSalesAmount] decimal(18,2) NOT NULL ,
[LoadKey] int NULL 
)
ON [DATA]
GO

CREATE TABLE [data].[Aggregation] (
[ColumnName] varchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[dataDate] date,
[profileDate] datetime  ,
[aggregationType] varchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[dataValue] decimal(18,2) NOT NULL ,

)
ON [DATA]
GO

So, the dataValue in the Aggregation table needs to be compared to the TotalSalesAmount in the ProfileReconciliation table. The dataDate in the Aggregation table matches up with the AggregationDate in the ProfileReconciliation table. The ProfileReconciliation table only contains data from a daily feed, so we only need to compare the dates that are in the ProfileReconciliation with the Aggregation table. I need to indicate weather the values of each table are equal and if not I need to show a flag indicating so. I started by selecting the data from the Aggregation table where the dataDate was in AggregationDate. I obviously have to cast the AggregationDate. I just have no clue where to head next or what the best approach to this is.

Example Data:
From ProfileReconciliation table

OPDCost 2012-10-08 17:43:51.000 2012-10-07 00:00:00.000 SUM(Total_Net_Cost_Amt) 21323923.00 5307

OPDS    2012-10-08 17:43:51.000 2012-10-07 00:00:00.000 SUM(Total_Net_Sales_Amt)    70753228.00 5307

From Aggregation table:

SPVData.fact.DayStoreProdCost   2012-10-07  2012-10-09 09:06:20.9167944     20970788.131400 
SPVData.fact.DayStoreProdExtra   2012-10-07     2012-10-09 09:03:19.1558724     70642458.910000 

So as you can see the amounts do not match up so we wwould want teh results to look like this:

**ProfileName  Date                      ProfileAmount AggregationAmount   Equal**
OPDCost      2012-10-07 00:00:00.000   21323923.00   20970788.13         0
OPDS         2012-10-07 00:00:00.000   70753228.00   70642458.91         0
  • 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-12T14:19:09+00:00Added an answer on June 12, 2026 at 2:19 pm
    Select p.ProfileName, p.AggregationDate,
    p.TotalSalesAmount as ProfileAmount, a.DataValue as AggregationAmount,
    Case When p.SalesAmount <> a.DataValue Then 1
    else 0
    end as Equal
    From Aggregation a 
    Inner Join ProfileReconcilation p On Convert(Date,p.AggregationDate) = a.DataDate
    

    If I’ve understood correctly, which I’m not sure I have…

    Not sure the Convert is necessary either, from your example looks like your DateTime has a data in it anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 tables in a DB with very similar schemas that need to
I have some data in a table that looks similar to this: Item Date
I have two similar tables which have data I need to display in a
I have a select statement that gathers data from one monthly-summary table like the
I have two database tables containing similar data - one is the amount of
I have five tables that are fairly similar in structure but different enough that
I have two tables that have virtually identical content and very similar structure. They
I have 5 tables (tbl1, tbl2, tbl3, tbl4, tbl5) that all have similar columns,
I have 3 similar tables, that would all have the same enum type field.
I have a table that has records with a structure similar to this.. ID

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.