Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL add table to "From" group, changes answer
    primarykey
    data
    text
    <p>I have a query that spits out a result:</p> <pre><code>Select Sum(Count(P.Create_Dtime)), From Player P Where Trunc(P.Create_Dtime) &gt;= To_Date('2012-mar-01','yyyy-mon-dd') And Trunc(P.Create_Dtime) &lt; To_Date('2015-sep-9','yyyy-mon-dd') Group By Trunc(P.Create_Dtime) Order By Trunc(P.create_Dtime) Asc </code></pre> <p>Result = 317827</p> <p>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:</p> <pre><code>Select Sum(Count(P.Create_Dtime)) From Player P, Feature_group_xref X Where Trunc(P.Create_Dtime) &gt;= To_Date('2012-mar-01','yyyy-mon-dd') And Trunc(P.Create_Dtime) &lt; To_Date('2015-sep-9','yyyy-mon-dd') Group By Trunc(P.Create_Dtime) Order By Trunc(P.create_Dtime) Asc </code></pre> <p>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.</p> <p>**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...</p> <pre><code>Select sysdate,sum(Count(p.init_dtime)) From Player p Where Trunc(p.Init_Dtime) &gt; Trunc(Sysdate) - 7 And Trunc(P.Create_Dtime) &gt;= To_Date('2012-mar-01','yyyy-mon-dd') And Trunc(P.Create_Dtime) &lt; To_Date('2015-sep-9','yyyy-mon-dd') Group By Trunc(P.Init_Dtime) Order By Trunc(p.Init_Dtime) Asc </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload