Sunday, October 18, 2015

Feeling Smug b/c My Database Query Works

I'm feeling pretty smug over here!

After three days of reading forum posts about the OpenOffice Base program I finally figured out the correct syntax for a query to select and manipulate information based on a specific date range.

Base is the free, open source version of MS Office's Access.

It was the date range syntax that was throwing me off, because it didn't follow exactly the SQL syntax as espoused by the w3schools tutorials. It didn't follow Access's syntax. The forum post that finally answered my question: https://forum.openoffice.org/en/forum/viewtopic.php?f=61&t=72504

Thank you, bhilton for asking your question and all the volunteers for helping her to reach the answer.

The code that I was trying to write:
SELECT "Listing", COUNT("Nights") AS TotalReservation, SUM( "Nights" ) AS TotalNightsSold, AVG( "Nights" ) AS AvgNightsPerRes FROM "Reservations" WHERE "Date" BETWEEN '2014-01-01' AND '2014-12-31' GROUP BY "Listing"
To make a table which grouped info by vacation house rental and showed me the total number of reservations in 2014, the total number of nights booked in 2014, the average number of nights per reservation.

With more data (and really, who doesn't like data?), I could find out the average number of people per reservation and which geographical locations provide the most/least bookings.

This sort of info would be handy in creating projections for future reservations, focusing marketing efforts on types of groups (family vs. 20 somethings traveling together), and focusing marketing efforts on locations (such as either marketing heavily on the east coast to tap into existing infrastructure, or moving into new market areas to expand.

And finally, thank you Drexel professor, whose name I don't remember at this moment, for being such a punk about us perfecting our SQL in the database class. It came in handy.

No comments: