I have this View and want to also see Clubs that do not have current memberships.
I have the IS NULL but not seeing the Clubs that do NOT have memberships.
attribute.PersonMembership is a SQL table that has membership information where the criteria are set for.
SELECT dbo.v060ClubOfficersPresOrNot.ClubNo, dbo.v060ClubOfficersPresOrNot.SortName, dbo.v060ClubOfficersPresOrNot.ClubName,
dbo.v060ClubOfficersPresOrNot.BSProgram, dbo.v060ClubOfficersPresOrNot.ClubSection, dbo.v060ClubOfficersPresOrNot.Code,
RTRIM(attribute.PersonMembership.InvoiceNumber) AS InvNo, dbo.v060ClubOfficersPresOrNot.President, dbo.v060ClubOfficersPresOrNot.Email,
dbo.v060ClubOfficersPresOrNot.Phone, dbo.v060ClubOfficersPresOrNot.FacilityName, dbo.v060ClubOfficersPresOrNot.StreetOne,
dbo.v060ClubOfficersPresOrNot.StreetTwo, dbo.v060ClubOfficersPresOrNot.City, dbo.v060ClubOfficersPresOrNot.State, dbo.v060ClubOfficersPresOrNot.PostalCode,
YEAR(attribute.PersonMembership.EndDate) AS YearEnd, attribute.PersonMembership.MembershipTypeId, dbo.v060ClubOfficersPresOrNot.URL,
dbo.v060ClubOfficersPresOrNot.Certified, dbo.v060ClubOfficersPresOrNot.FacilityLastUpdate, dbo.v060ClubOfficersPresOrNot.ByLawsUploadDate,
dbo.v060ClubOfficersPresOrNot.ProgramStatusId, dbo.v060ClubOfficersPresOrNot.Status
FROM attribute.PersonMembership RIGHT OUTER JOIN
dbo.v060ClubOfficersPresOrNot ON attribute.PersonMembership.OrganizationId = dbo.v060ClubOfficersPresOrNot.ClubID
WHERE (DAY(attribute.PersonMembership.EndDate) = 30 OR
DAY(attribute.PersonMembership.EndDate) IS NULL) AND (MONTH(attribute.PersonMembership.EndDate) = 6 OR
MONTH(attribute.PersonMembership.EndDate) IS NULL) AND (YEAR(attribute.PersonMembership.EndDate) BETWEEN YEAR(GETDATE()) AND YEAR(GETDATE()) + 1 OR
YEAR(attribute.PersonMembership.EndDate) IS NULL) AND (attribute.PersonMembership.MembershipTypeId IN (1, 2, 4) OR
attribute.PersonMembership.MembershipTypeId IS NULL) OR
(DAY(attribute.PersonMembership.EndDate) = 30 OR
DAY(attribute.PersonMembership.EndDate) IS NULL) AND (MONTH(attribute.PersonMembership.EndDate) = 6 OR
MONTH(attribute.PersonMembership.EndDate) IS NULL) AND (YEAR(attribute.PersonMembership.EndDate) BETWEEN YEAR(GETDATE()) AND YEAR(GETDATE()) + 4 OR
YEAR(attribute.PersonMembership.EndDate) IS NULL) AND (attribute.PersonMembership.MembershipTypeId = 3 OR
attribute.PersonMembership.MembershipTypeId IS NULL)
There's probably a better way to limit the month, day and year range than the way I have it too ...
The final report is in Crystal Reports with a EndYear parameter where the end-user enters the membership ending year.
Right now they are entering to see all of the clubs with current
memberships and would like to see the clubs without current memberships.
So the result basically they are seeing are:
-
Club 1 has 15 memberships
-
Club 2 has 10 memberships
-
Club 3 has 0 memberships or Null memberships <-- trying to get
this to show. Knowing that Club 5305 had 15 memberships in 2015 so when
the end-user enters 2015 in the prompt they would see Club 5305 with 15
memberships but when they enter 2016 they would still see 5305 but it
would either say 0 or null memberships but still listing Club 5305
The "v060ClubOfficersPresOrNot" table consists of the following clubs as the sampling:
-
ClubNo 5305 - one at issue, has memberships in 2015 but none in 2016 yet not showing up
-
ClubNo 1617 - has no president but clubs should show and any memberships within the parameters should show
-
ClubNo 22 - has president and clubs should show with any memberships within the parameters
-
ClubNo 8004 - has no memberships in the period and does show up
The "PersonMembership" has all the membership records from 2015 through 2019 of membertypeid 1-4 for the sampling.
Since the syntax used in Access do not carry over without modifications to SQL, would appreciate the SQL syntax to make it work.
And if you know the proper SQL syntax for "Between
Year(Date())+IIf(Month(Date())>=7,1,0) And
Year(Date())+IIf(Month(Date())>=7,1,0)+4" instead of what I currently
have in SQL, that would be wonderful.