Anthony Matovu
asked on
Run a query from result of another query - vb.net
I have the two queries below and i would want query two to be summaries from the results of query 1, I don't option for combining the two queries because the data source is too big and therefore query would take long.
Anthony
1. tsql = "select id as userid, total_rev_amt, usage_type_nm, dedicated_account_used_cd from fct_subs_marketing_snapd " _
& " where snapshot_date_key = 20150101
2. 'select userid, sum(total_rev_amt) as rev_tot,sum(case when usage_type_nm = 'DATA' then total_rev_amt else 0 end) as rev_dat
from temp group by userid
[result of the above query]
Anthony
1. tsql = "select id as userid, total_rev_amt, usage_type_nm, dedicated_account_used_cd from fct_subs_marketing_snapd " _
& " where snapshot_date_key = 20150101
2. 'select userid, sum(total_rev_amt) as rev_tot,sum(case when usage_type_nm = 'DATA' then total_rev_amt else 0 end) as rev_dat
from temp group by userid
[result of the above query]
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In terms of SQL,
1> you can first fire query 1 and store the results in a temp table or a in memory table.
Open in new window
2> And in query 2 use the temp table or the in memory table generated in step 1.you can also combine both of these statements in a stored procedure and call that stored procedure from .NET.