1
我使用下面的查詢基於如下3個條件從表中獲得唯一的記錄計數:如何使用表格上的oneColumn和Union上的Distinct獲取所有列?
Select COUNT(*) FROM ( select distinct(SUBSCRIBER_EMAIL) from SUBSCRIBER where SUBSCRIBER_ACTIVE = 1 and SUBSCRIBER_ZIP between '30000' and '31999'
Union
select distinct(SUBSCRIBER_EMAIL) from SUBSCRIBER where SUBSCRIBER_ACTIVE = 1 and SUBSCRIBER_ZIP between '39813' and '39901'
Union
select distinct(SUBSCRIBER_EMAIL) from SUBSCRIBER where SUBSCRIBER_ACTIVE = 1 and SUBSCRIBER_ZIP between '32000' and '34999'
) Counts
現在我想的是:我想要得到的這些記錄的所有數據..
我已經試過
Select distinct(SUBSCRIBER_EMAIL), SUBSCRIBER_Id FROM (select distinct(SUBSCRIBER_EMAIL),SUBSCRIBER_ID from SUBSCRIBER where SUBSCRIBER_ACTIVE = 1 and SUBSCRIBER_ZIP between '30000' and '31999'
Union
select distinct(SUBSCRIBER_EMAIL),SUBSCRIBER_ID from SUBSCRIBER where SUBSCRIBER_ACTIVE = 1 and SUBSCRIBER_ZIP between '39813' and '39901'
Union
select distinct(SUBSCRIBER_EMAIL),SUBSCRIBER_ID from SUBSCRIBER where SUBSCRIBER_ACTIVE = 1 and SUBSCRIBER_ZIP between '32000' and '34999'
) x
但使用此我得到的所有記錄,意味着截然不同的是不是在這種情況下工作。
請幫助我如何獲得與其他數據不同的電子郵件地址。
沒有我已經試過這個,它不工作.. –
你是否得到任何錯誤,或者它只是不返回你想要的? – vlio20