Is it possible to get the result as below from the same table date-wise records:
Enrolled Enrolled as Email Enrolled as Text Deals Redeemed
<First Date> 7 5 2 6
<Next Date> 9 3 6 14
Table structure look something like this:
Customer_id, field1, field2, responsecode, created_date
My current query is something like this:
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
Which works fine for the first three columns but for the four column that is “Deals redeemed” which is a sub query from another table.
Select COUNT(*) from tbl_TransactionDishout where DishoutResponseCode = '0000'
Table Structure is as below:
Table name is “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
Can you try like this. (The Deals_Redeemed value will be same for all rows, you said there is no relation between two tables)