Thank you in advance for your help. I have been working on this problem for hours. I have a table with the following columns:
OrderID | CustomerID | Date | Course
--------|------------|-----------|----------
14954 | 13440 |16.10.2016 | Zürich
14955 | 13441 |17.10.2016 | Bern
14956 | 13441 |17.10.2016 | Aargau
14957 | 13442 |17.10.2016 | Bern
14958 | 10483 |17.10.2016 | Zürich
14959 | 13442 |18.10.2016 | Solothurn
I'd like to count the customer's first order, which was received on a certain date broken down by course. The query should yield the following result for the 17.10.2016.
Bern: 2
Aargau: 0
Zürich: 1
I've already tried a DISTINCT and nested Query like:
SELECT Count(*) AS Anzahl
FROM (SELECT DISTINCT kundennummer
FROM (SELECT datum,
kundennummer
FROM unterlagenbestellungen
WHERE kurs LIKE
'%" & DgvStatUnterlagenbestellungen.Rows(x).HeaderCell.Value & "%')
WHERE datum BETWEEN # " & mindatum & " # AND # " & maxdatum & " # )
I'm very thankful for any help