I have table with data like this
| price | date | type |
|---|---|---|
| 1000 | 2021-03-13 | A |
| 1000 | 2021-03-14 | A |
| 1000 | 2021-03-15 | A |
| 1300 | 2021-03-16 | A |
| 1000 | 2021-03-17 | A |
| 1300 | 2021-03-18 | A |
| 1000 | 2021-03-19 | A |
| 1500 | 2021-03-20 | A |
| 1500 | 2021-03-21 | A |
| 1500 | 2021-03-22 | A |
| 2000 | 2021-03-13 | B |
| 2000 | 2021-03-14 | B |
| 2000 | 2021-03-15 | B |
| 2000 | 2021-03-16 | B |
| 2000 | 2021-03-17 | B |
I want to query data like this
| price | startDate | endDate | type |
|---|---|---|---|
| 1000 | 2021-03-13 | 2021-03-15 | A |
| 1300 | 2021-03-16 | 2021-03-16 | A |
| 1000 | 2021-03-17 | 2021-03-17 | A |
| 1300 | 2021-03-18 | 2021-03-18 | A |
| 1000 | 2021-03-19 | 2021-03-19 | A |
| 1500 | 2021-03-20 | 2021-03-22 | A |
| 2000 | 2021-03-13 | 2021-03-17 | B |
my current sql below but it is not correct at all
SELECT MIN(date) as startDate, MAX(date) as endDate, price, type
FROM prices
GROUP BY type, price
ORDER BY type, MIN(date)
