Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7633631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:56:19+00:00 2026-05-31T06:56:19+00:00

Table Structures: tblCustomer Customer_id created field1 field2 cardno field14 ———————————————————————————————— 1014 2010-05-25 12:51:59.547 Cell

  • 0

Table Structures:
tblCustomer

Customer_id  created                 field1            field2        cardno       field14
------------------------------------------------------------------------------------------------    
1014         2010-05-25 12:51:59.547 Cell Phone        abc@lmn.com   1234567890   Test Card
1015         2010-08-15 12:51:59.547 Email             abc@xyz.com   2345678891   NULL

tbl_TransactionDishout

Trnx_id   offerNo   TerminalID      Created                  VirtualCard
-------------------------------------------------------------------
1         1014      170924690436418 2010-05-25 12:51:59.547  1234567890

Relation between tbl_transaction and tblCustomer is having same cardno.

Existing query

SELECT 
convert(varchar, CAST(t2.created AS DATETIME), 111) created, 
COUNT(CASE WHEN t2.DishoutResponseCode = '0000' and t1.field14 <> 'Test card' THEN 1      END) as  Deals_Redeemed,
COUNT(CASE WHEN t2.DishoutResponseCode <> '0000' and t1.field14 <> 'Test card' THEN 1   END) as Non_Deals 
FROM tblCustomer AS t1, tbl_TransactionDishout t2 
where t1.cardno = t2.VirtualCard
and convert(varchar, CAST(t2.created AS DATETIME), 111) >= (select        MAX(convert(varchar, a.Created, 111)) 
from tbl_Offer as a,tbl_TransactionDishout as b where cast(a.OFID as varchar) =     b.OfferNo and a.Live = '1')
GROUP BY convert(varchar, CAST(t2.created AS DATETIME), 111) 
ORDER BY convert(varchar, CAST(t2.created AS DATETIME), 111) DESC       



created     Deals_Redeemed  Non_Deals    
-------------------------------------
2012/03/02  0               0
2012/03/01  0               1
2012/02/28  2               0
2012/02/27  0               0      

Now I want the rows with non-zero counts..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:56:22+00:00Added an answer on May 31, 2026 at 6:56 am

    Use a HAVING clause.

    Just after your GROUP BY put:

    HAVING  COUNT(CASE WHEN t2.DishoutResponseCode = '0000' and t1.field14 <> 'Test card' THEN 1      END) > 0
    AND COUNT(CASE WHEN t2.DishoutResponseCode <> '0000' and t1.field14 <> 'Test card' THEN 1   END) > 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Table Structures: tblCustomer Customer_id created field1 field2 cardno field14 ------------------------------------------------------------------------------------------------ 1014 2010-05-25 12:51:59.547 Cell
Table Structures: tblCustomer Customer_id created field1 field2 cardno field14 ------------------------------------------------------------------------------------------------ 1014 2010-05-25 12:51:59.547 Cell
Table Structures: tblCustomer Customer_id created field1 field2 cardno -------------------------------------------------------- 1014 Test1 Cell Phone 123146
I have the following table structures. Table A id name 1 name1 2 name2
I found the following table structures while I was watching ruby on rails tutorial.
Say I have a database called Poll and have these two table structures. poll
I'm trying to bind a table of structures to a DataGridView. Loading and viewing
I have two tables with the following (simplified) structures: table "Factors" which holds data
I have a table TreeStructures wich holds structures of Trees. This table has columns
I have quite a few situations where I have database structures similar to: TABLE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.