I am trying to combine 5 queries into one query so that I do not have to run multiple queries every time I want to update the report. Each of the 5 reports is formatted so the result looks like:
The_Date Sp_DAU CS_Dau
01-Jan-12 3423 3674
02-Jan-12 1823 2547
and so on….(different columns for each, EXCEPT The_Date stays the same)
The problem is, The_Date comes from multiple tables so I don’t know how to combine all the querys so the result looks like:
The_Date Sp_Dau Cs_Dau TapJoy_Ios_Dau TapJoy_Android_DAU Portal_DAU
01-Jan-12 1823 2547 35 1115 33
02-Jan-12 2453 3000 47 1478 30
Does this make sense? Would it help if I posted all of the queries or is that too much information?
Looking at the second table, I’m assuming you’ll always want to aggregate this data based on the date. As long as that’s the case, you’ll want to JOIN based on the date for your number, N, of tables.
If your date is a SQL datetime, you’ll probably want to round to the same exact day. That gets a little more complicated, since you’ll need to use
CAST( CAST( The_Date as INT) AS DATETIME)in each place that a datetime is referenced, including the joins.Hope that helps.