I have a query that spits out a result:
Select Sum(Count(P.Create_Dtime)),
From Player P
Where
Trunc(P.Create_Dtime) >= To_Date('2012-mar-01','yyyy-mon-dd')
And Trunc(P.Create_Dtime) < To_Date('2015-sep-9','yyyy-mon-dd')
Group By Trunc(P.Create_Dtime)
Order By Trunc(P.create_Dtime) Asc
Result = 317827
Now,when I change this query to add another table to the from group (i will be adding constraints based on this table later on)…the result spits out a new answer with a sum much larger than the original. For example, the original answer was 317827, and now when I add in the table below, the answer comes out to 6356540, exactly 20x the original answer. There are 20 rows of data in the “Feature_group_xref” table, and the create_dtime column is also in that table. Why are these values multiplying? I assumed that because i have identified each column (with “P”) that it shouldn’t be a problem. Any suggestions? If you see below the only thing I added was a new table name:
Select Sum(Count(P.Create_Dtime))
From Player P, Feature_group_xref X
Where
Trunc(P.Create_Dtime) >= To_Date('2012-mar-01','yyyy-mon-dd')
And Trunc(P.Create_Dtime) < To_Date('2015-sep-9','yyyy-mon-dd')
Group By Trunc(P.Create_Dtime)
Order By Trunc(P.create_Dtime) Asc
Result = 6356540 (There are 20 rows in table “Feature_Group_Xref” and one column is create_dtime. This result is exactly 20x the result in the first query.
**UPDATE – I have this query which gives me the sum of active players within the last 7 days for users created after march 1 2012…
Select
sysdate,sum(Count(p.init_dtime))
From Player p
Where
Trunc(p.Init_Dtime) > Trunc(Sysdate) - 7
And
Trunc(P.Create_Dtime) >= To_Date('2012-mar-01','yyyy-mon-dd')
And Trunc(P.Create_Dtime) < To_Date('2015-sep-9','yyyy-mon-dd')
Group By Trunc(P.Init_Dtime)
Order By Trunc(p.Init_Dtime) Asc
I want to take this query and break it down so that the only (init_dtime) values that show up are the ones where group_id = 1,10,20,30, and 40 (Group ids are 1-100). Group ID can be found in the player_source table, and the column “player_id” is located in both the player and player_source table if that helps.
If two tables in a join query (From Player P, Feature_group_xref X in your case) have no join condition then RDBMS returns their Cartesian Product. That means that each row of one table combines with each row of another. For example if one table has 3 rows and another table has 3 rows then if you join those two tables without join condition you will get 9 rows.