I have this sample where I am counting the number of records and displaying them as `CustomerIDCount`. I would also like to include the `LatestDate` but I am not sure if I need another query or I can add it to this one?

[SQLFiddle](http://www.sqlfiddle.com/#!18/a4acd6/1)

Setup

```sql
CREATE TABLE log
(
    [CustomerID] [int] NULL, 
    [LogDate] [datetime] NULL
);

INSERT INTO log ([CustomerID], [LogDate])
VALUES
    (1, 2021-02-12),
    (2, 2021-02-12),
    (1, 2021-02-12),
    (3, 2021-03-12),
    (4, 2021-02-12)
;

```

My attempt:

```sql
SELECT
    CustomerID, COUNT(*) CustomerIDCount
FROM
    (SELECT  CustomerID
     FROM log) g
GROUP BY
    CustomerID
ORDER BY 
    CustomerIDCount

```

Results:

| CustomerID | CustomerIDCount |
| --- | --- |
| 2 | 1 |
| 3 | 1 |
| 4 | 1 |
| 1 | 2 |

But my desired results would be:

| CustomerID | CustomerIDCount | LatestDate |
| --- | --- | --- |
| 2 | 1 | 2021-02-12 |
| 3 | 1 | 2021-03-12 |
| 4 | 1 | 2021-02-12 |
| 1 | 2 | 2021-03-12 |