Why am I getting an invalid column reference 's' error with this query?
<p>Something is likely wrong with the inner join here, since the two queries I'm joining are fine if run separately, but I can't figure out what... :( I'm sorry for what's probably an easy question for most of you here!</p>

<p>I tried not referencing the s as users, but I still get the invalid column reference error...</p>

<pre><code>SELECT time_spent_bucket, totalrev
FROM
(
SELECT session_aggregate.app_timespent AS time_spent_bucket, COUNT(*) AS users
FROM
    (
    SELECT session_info.s, 
    case when SUM(session_info.session_length)/60 &gt; 200 then "200+" 
    when SUM(session_info.session_length)/60 &gt;= 100 then "100 &lt;-&gt; 200" 
    when SUM(session_info.session_length)/60 &gt;= 50 then "50 &lt;-&gt; 99"
    when SUM(session_info.session_length)/60 &gt;= 20 then "20 &lt;-&gt; 49"
    when SUM(session_info.session_length)/60 &gt;= 10 then "10 &lt;-&gt; 19"
    when SUM(session_info.session_length)/60 &gt;= 5 then "5 &lt;-&gt; 9"
    else "&lt;5" end AS app_timespent
    FROM
        (
        SELECT kt_session(calc_session.s, calc_session.evt_lst, 5) AS (s, session_number, session_length)
        FROM 
            (
            SELECT session_set.s, collect_set(session_set.timestamps) evt_lst
            FROM 
                (
                SELECT total_list.s, total_list.timestamps
                FROM 
                    (
                    SELECT s, utc_timestamp AS timestamps
                    FROM appl9_evt
                    WHERE month = 201512
                    and s is not null
                    UNION ALL
                    SELECT s, utc_timestamp AS timestamps
                    FROM appl9_evt
                    WHERE month = 201512
                    and s is not null
                    ) total_list 
                )session_set
            GROUP BY session_set.s
            ) calc_session 
        ORDER BY s,session_number DESC
        )session_info
    GROUP BY session_info.s
    )session_aggregate
GROUP BY session_aggregate.app_timespent
ORDER BY time_spent_bucket) ts
INNER JOIN
(
SELECT s, v
FROM appl9_mtu
WHERE month = "201507"
GROUP BY s, v
        ) totalrev
ON totalrev.s = ts.s
</code></pre>