MySQL Forums
Forum List  »  Oracle

SQL Query Help - 2 Queries
Posted by: Craig Blakemore
Date: January 20, 2014 08:31AM

Hi all

Got a problem with a query, not sure what command to use, Tried and tried, now trying a union but its not giving me what I want

Basically for example, I want a count of customers that created their account (CreatedDate) in Nov 13, and then the next column to look of the customers that created an account, fully registered in or 21 days after the month (RegisteredDate)

So first column need a count of CreatedDate 1-11-2013 to 30-11-2013
then of those who registered RegisteredDate between 1-11-2013 - 21-12-2013

Here is what I have gotten to


Select Date_Format(PlayerAccounts.CreatedDate,"%M,%Y"), AffiliateName,
Count(CreatedDate), Count(RegisteredDate)
from PlayerAccounts, Affiliates
Where
PlayerAccounts.AffiliateID = Affiliates.AffiliateID
and CreatedDate Between "2013-11-01" and "2013-12-01"
Union
Select
Date_Format(PlayerAccounts.CreatedDate,"%M,%Y"), AffiliateName,
Count(CreatedDate), Count(RegisteredDate)
from PlayerAccounts, Affiliates
Where
PlayerAccounts.AffiliateID = Affiliates.AffiliateID
and CreatedDate Between "2013-11-01" and "2013-12-01"
and RegisteredDate between "2013-11-01" and "2013-12-22"

Group By AffiliateName


Would be very greatful for any help

Thanks
Craig

Options: ReplyQuote


Subject
Views
Written By
Posted
SQL Query Help - 2 Queries
3081
January 20, 2014 08:31AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.