另一個子查詢是否有可能從同一個表日期明智的記錄得到如下結果:Ading在現有子查詢
Enrolled Enrolled as Email Enrolled as Text Deals Redeemed
<First Date> 7 5 2 6
<Next Date> 9 3 6 14
表結構是這個樣子:
Customer_id, field1, field2, responsecode, created_date
我當前的查詢是這樣的:
select created_date,
count(field1) Enrolled,
count(case field1 when 'E-mail' then 1 end) Enrolled_as_Email,
count(case field1 when 'Cell Phone' then 1 end) Enrolled_as_Cell,
count(responsecode) Deals_Redeemed
from tblCustomer
group by created_date
order by created_date
這對於前三列,但對日工作正常e四列是「Deals redeemed」,這是來自另一個表的子查詢。
Select COUNT(*) from tbl_TransactionDishout where DishoutResponseCode = '0000'
表結構如下:
表名是 「tbl_TransactionDishout」
[Trnx_ID] [int] IDENTITY(1,1) NOT NULL,
[OfferNo] [nvarchar](50) NULL,
[MerchantID] [nvarchar](50) NULL,
[TerminalID] [nvarchar](50) NULL,
[DishoutResponseCode] [nvarchar](50) NULL,
[Created] [datetime] NULL
什麼是tblCustomer和tbl_TransactionDishout之間的關係?它是否爲DishoutResponseCode的響應碼? – arunes 2012-03-01 07:11:08
它們之間沒有任何關係..我只希望結果以日期順序顯示.. – 2012-03-01 07:14:16