Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Dmitriev Denis
Dmitriev Denis
1,281 Points

I don't know how to built up thiw query else using simultaneously WHERE and ORDER BY

How to built it right?

1 Answer

Ebenezer Odoi
Ebenezer Odoi
8,140 Points

This is an example using Where and Order By:

SELECT TotalRooms = COUNT(*) , StartDate = MIN(i.StartDate) , EndDate = MAX(i.EndDate) FROM bookings b WHERE MIN(i.StartDate) >= '2010-01-01'

ORDER BY StartDate, EndDate

I hope it helps out.