

We have three locations: HQ, Downtown, and 1st Street. ('HQ', 'Bagel', 3, NOW() - INTERVAL '3 day' - INTERVAL '1 hour')

('1st Street', 'Bagel', 3, NOW() - INTERVAL '2 day' - INTERVAL '1 hour'), INSERT INTO sales(location, product, price, sold_at) VALUES

Let's create the table and insert some sales data: CREATE TABLE sales( But for illustrating the GROUP BY concepts we'll just use simple TEXT columns. If we were building this table in a real application we'd set up foreign keys to other tables (like locations or products). We'll call this table sales, and it will be a simple representation of store sales: the location name, product name, price, and the time it was sold. You will learn and remember far more by working through these examples rather than just reading them.ĪDVERTISEMENT Setting up the data (creating sales)įor our examples we'll use a table that stores the sales records of various products across different store locations. I encourage you to follow along with these examples and run these queries for yourself. Note: I've cleaned up the psql output in these examples to make it easier to read, so don't worry if the output shown here isn't exactly what you've seen in your terminal. You are now connected to database "fcc" as user "john". Next let's start the interactive console by using the command psql, and connect to the database we just made using \c : $ psql With PostgreSQL already installed, we can run the command createdb at our terminal to create a new database. If you have another database client that you enjoy working with that's fine too. To work with our PostgreSQL database, we can use psql-the interactive PostgreSQL command line program. Setting up example data (creating sales)īefore we can write our queries we need to setup our database.įor these examples we'll be using PostgreSQL, but the queries and concepts shown here will easily translate to any other modern database system (like MySQL, SQL Server, and so on).
PSEQUEL SUM PER DATE RANGE HOW TO
In this article we'll look at how to construct a GROUP BY clause, what it does to your query, and how you can use it to perform aggregations and collect insights about your data. Intervening, Ryan has Miller sent to prison and kills his younger brother Patrick.The GROUP BY clause is a powerful but sometimes tricky statement to think about.Įven eight years later, every time I use a GROUP BY I have to stop and think about what it's actually doing. Retired Jack is on vacation in London with his family when he witnesses a terrorist attack on the Queen Mother – in the book, it was the Prince and Princess of Wales. Playing the film's antagonist Sean Miller, a member of an IRA splinter cell, was Sean Bean, while James Earl Jones is the sole representative from Red October, reprising his role as Ryan's mentor James Greer. (Baldwin was unable to commit to the series, so the part was recast with the imminently bankable Star Wars actor). Not only that, Ryan had undergone a face-swap and was now played by Harrison Ford. Patriot Games (1992)Ĭlancy's second Ryan adventure, published in 1987, was actually set before the events of The Hunt for Red October though the film version is, in fact, set after. With innovative stealth tech, the sub was practically invisible and headed towards the Eastern seaboard of the US alerting a certain former Marine-turned-analyst to its presence.After some sub-on-sub action, it turned out Ramiu was defecting and Ryan worked with the captain on getting him to the "new world", America.Ĭritics and audiences loved the film, with universally positive reviews and a box office take of over $200 million. The 'Red October' of the title was a Soviet nuclear submarine captained by Marko Ramiu, a Russian played by obvious first choice Connery (though, we will add, he did pick up a BAFTA nomination for his performance).
