Tag Info

New answers tagged


But the execution plan for both is same as shown below: The plans are different. One is an inner join, the other is an outer join. The results may be the same in your simple test, but the semantics are different. In more complex queries, the difference may cause more obviously different execution plans, and come with a performance impact. There are ...


My dilemma is about utility and advantages of using CROSS APPLY and CTE. Are there any or its just exotic? For small datasets the optimizer is probably not bothering with extensive analysis. However, if one were to look at competing plans for large data sets (say millions of Orders or Items from your example), then CROSS APPLY, especially if Items are ...


Thanks for all your efforts, I did this way. select a.emp_id, a.total, b.TOTAL_CALLS from (SELECT a.emp_id,count(*) total FROM `Dash_Agent_Disp` a where a.call_type = 'sales' GROUP BY a.emp_id) a, (select emp_id, count(*) total_calls from `Dash_Agent_Disp` group by emp_id) b WHERE a.emp_id=b.emp_id Thanks All.


You need to filter you subquery with call_type='SALES', then run: I use your information: INSERT INTO test.Dash_Agent_Disp (id,emp_id,call_start,call_end,call_type) VALUES ('1','20043','20:20:10','20:21:19','SALES'), ('2','20043','20:25:34','20:27:12','NON-SALES'), ('3','20044','21:25:34','21:27:12','SALES'), ...

Top 50 recent answers are included