CREATE  VIEW v_LoyaltyDetail
AS
SELECT	M.recId,
		S.recId storeId, S.storeCode, S.storeName,
		G.recId groupId, G.groupCode, G.groupName,
		M.name,M.surname,M.idNumber,M.mobileNo,M.email,
		M.loyaltyNumber,M.optIn,M.isActive,M.dateCreated,M.dateUpdated
FROM	pal_LoyaltyMember M
		JOIN pal_LoyaltyGroup G
			ON G.recId = M.loyaltyGroupId
		JOIN pal_LoyaltyStore S
			ON S.recId = M.loyaltyStoreId
