Hello,
My first post
I would like to write the following SQL in VBA :
Return all Costumers who bought BETWEEN 2 AND 6 TV's
AND also bought BETWEEN 2 AND 6 Cameras
1. Until the HAVING part - all working fine! What am I doing wrong?
2. Is it possible to add multiple conditions to HAVING?
My first post

I would like to write the following SQL in VBA :
Return all Costumers who bought BETWEEN 2 AND 6 TV's
AND also bought BETWEEN 2 AND 6 Cameras
1. Until the HAVING part - all working fine! What am I doing wrong?
2. Is it possible to add multiple conditions to HAVING?

Code:
Sub SQLinVBA ()
Product1 = TV
Product2 = Camera
" SELECT [Costumer], [Product Name], [Product Description],
count([Product Description]) " & _
" FROM Table " & _
" WHERE [Product Description] IN (" & Chr$(39) & Product1 & Chr$(39) & "," & Chr$(39) & Product2 & Chr$(39) & ") " & _
" GROUP BY [Costumer], [Product Name], [Product Description] " & _
" HAVING count([Product Description]) BETWEEN 2 AND 6 AND [Product Description] = " Product1 & _
" AND " & _
" HAVING count([Product Description]) BETWEEN 8 AND 12 AND [Product Description] = " Product2
End sub