2014-04-09 17 views
0

如何使用五種不同的SQL查詢在相同的GridView控件從同一個表使用不同的參數如何使用五種不同的SQL查詢在相同的GridView控件從同一個表

select count(distinct callingnumber) as UniqueCaller,count(callingnumber) as  numberOfCall from FCR1 where callnumberpercallreason >15; 

select count(distinct callingnumber) as UniqueCaller,count(callingnumber) as numberOfCall from FCR1 where callnumberpercallreason between 2 and 6 and callreasonname='Mobile/GSM>VAS-CRBT>CRBT Service Deactivation'; 

===== ====輸出============

Calling frequency Unique Caller No of Call 
15     7    116 
B/n 14-11   11    133 
B/n 10-8   50    412 
B/n 7-2    8528   20635 
One Times   46219   46219 
Total    54815   67515 
+1

如果選定的列相同,則可以使用「union」。 – Bharadwaj

回答

0

如果你的列是相同的,你可以這樣使用兩個查詢之間的聯盟:

select count(distinct callingnumber) as UniqueCaller,count(callingnumber) as  numberOfCall from FCR1 where callnumberpercallreason >15; 
union 
select count(distinct callingnumber) as UniqueCaller,count(callingnumber) as numberOfCall from FCR1 where callnumberpercallreason between 2 and 6 and callreasonname='Mobile/GSM>VAS-CRBT>CRBT Service Deactivation'; 

如果您的列不同,您可以爲不同的列創建空白:例如:

select col1, col2, col3 from table1 
union 
select col1, '', col4 from table2 
相關問題