Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Joining two tables on date fields summed.

$
0
0

Hi,

I have a project I'm working on that has two SQL tables. I need to create a query that joins the two tables by org level and by date.

Table 1 has the date columns like this :

January February March - etc

And in each of these month columns is an overtime amount for that month (in dollars).

Table2 has it's date columns that are 'real' date time columns like this ' 2013-03-22 00:00:00.000'. These are stamped every time a payroll is run (every week or so)


What I need to do is write a query that joins table1 to table2 so that I join all the months in table 2 and sum the amount.

In other words January I would need to grab all the 01 records from table 2 and then join to the January column and then compare the amounts. Table 1 has the budgeted amounts for the year, table 2 is all the actual amounts.


qeqw


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>