I have been trying to create a query for the past week or so now using the following query as a reference and needed some help breaking it down, so I know what each section does.
Select Distinct
tblCustomers.fldEmail
, tblCustomers.fldCustomerID
, tblCustomers.fldName
, tblCustomers.fldContactName
From tblBigClubs
Inner Join tblBigClubMatch
On tblBigClubs.fldBigClubID = tblBigClubMatch.fldBigClubID
Inner Join tblCustomers
On tblBigClubMatch.fldCustomerID = tblCustomers.fldCustomerID
Where (tblBigClubs.fldBigClubID In (Select Distinct
dbo.tblBigClubMatch.fldBigClubID
From dbo.tblOrders
Inner Join dbo.tblOrderItems
On dbo.tblOrders.fldOrderID = dbo.tblOrderItems.fldOrderID
Inner Join dbo.tblBigClubMatch
On dbo.tblOrders.fldCustomerID = dbo.tblBigClubMatch.fldCustomerID
Where (dbo.tblOrders.fldOrderDate > DateAdd(Year, -2, GetDate()))
And (dbo.tblOrderItems.fldStockCode Like 'TO%')
Group By dbo.tblBigClubMatch.fldBigClubID
Having (Sum(dbo.tblOrderItems.fldQtyOrder) >= 30))
And tblCustomers.fldEmail Is Not Null
And dbo.tblCustomers.fldEmail <> ''
And Len(dbo.tblCustomers.fldEmail) > 8
);
Please can someone explain what each section is doing?