Rewrote some sql quierries.
CaseConstuctor is still wrong have to look at it again tomorrow.
Max doesn't work with timestamp.
Not sure about group by.
Implemented distinct operator.