Stay Ahead, Stay ONMINE

Practical SQL Puzzles That Will Level Up Your Skill

There are some Sql patterns that, once you know them, you start seeing them everywhere. The solutions to the puzzles that I will show you today are actually very simple SQL queries, but understanding the concept behind them will surely unlock new solutions to the queries you write on a day-to-day basis. These challenges are all based on real-world scenarios, as over the past few months I made a point of writing down every puzzle-like query that I had to build. I also encourage you to try them for yourself, so that you can challenge yourself first, which will improve your learning! All queries to generate the datasets will be provided in a PostgreSQL and DuckDB-friendly syntax, so that you can easily copy and play with them. At the end I will also provide you a link to a GitHub repo containing all the code, as well as the answer to the bonus challenge I will leave for you! I organized these puzzles in order of increasing difficulty, so, if you find the first ones too easy, at least take a look at the last one, which uses a technique that I truly believe you won’t have seen before. Okay, let’s get started. I love this puzzle because of how short and simple the final query is, even though it deals with many edge cases. The data for this challenge shows tickets moving in between Kanban stages, and the objective is to find how long, on average, tickets stay in the Doing stage. The data contains the ID of the ticket, the date the ticket was created, the date of the move, and the “from” and “to” stages of the move. The stages present are New, Doing, Review, and Done. Some things you need to know (edge cases): Tickets can move backwards, meaning tickets can go back to the Doing stage. You should not include tickets that are still stuck in the Doing stage, as there is no way to know how long they will stay there for. Tickets are not always created in the New stage. “`SQL CREATE TABLE ticket_moves ( ticket_id INT NOT NULL, create_date DATE NOT NULL, move_date DATE NOT NULL, from_stage TEXT NOT NULL, to_stage TEXT NOT NULL ); “` “`SQL INSERT INTO ticket_moves (ticket_id, create_date, move_date, from_stage, to_stage) VALUES — Ticket 1: Created in “New”, then moves to Doing, Review, Done. (1, ‘2024-09-01’, ‘2024-09-03’, ‘New’, ‘Doing’), (1, ‘2024-09-01’, ‘2024-09-07’, ‘Doing’, ‘Review’), (1, ‘2024-09-01’, ‘2024-09-10’, ‘Review’, ‘Done’), — Ticket 2: Created in “New”, then moves: New → Doing → Review → Doing again → Review. (2, ‘2024-09-05’, ‘2024-09-08’, ‘New’, ‘Doing’), (2, ‘2024-09-05’, ‘2024-09-12’, ‘Doing’, ‘Review’), (2, ‘2024-09-05’, ‘2024-09-15’, ‘Review’, ‘Doing’), (2, ‘2024-09-05’, ‘2024-09-20’, ‘Doing’, ‘Review’), — Ticket 3: Created in “New”, then moves to Doing. (Edge case: no subsequent move from Doing.) (3, ‘2024-09-10’, ‘2024-09-16’, ‘New’, ‘Doing’), — Ticket 4: Created already in “Doing”, then moves to Review. (4, ‘2024-09-15’, ‘2024-09-22’, ‘Doing’, ‘Review’); “` A summary of the data: Ticket 1: Created in the New stage, moves normally to Doing, then Review, and then Done. Ticket 2: Created in New, then moves: New → Doing → Review → Doing again → Review. Ticket 3: Created in New, moves to Doing, but it is still stuck there. Ticket 4: Created in the Doing stage, moves to Review afterward. It might be a good idea to stop for a bit and think how you would deal with this. Can you find out how long a ticket stays on a single stage? Honestly, this sounds intimidating at first, and it looks like it will be a nightmare to deal with all the edge cases. Let me show you the full solution to the problem, and then I will explain what is happening afterward. “`SQL WITH stage_intervals AS (     SELECT         ticket_id,         from_stage,         move_date          – COALESCE(             LAG(move_date) OVER (                 PARTITION BY ticket_id                  ORDER BY move_date             ),              create_date         ) AS days_in_stage     FROM         ticket_moves ) SELECT     SUM(days_in_stage) / COUNT(DISTINCT ticket_id) as avg_days_in_doing FROM     stage_intervals WHERE     from_stage = ‘Doing’; “` The first CTE uses the LAG function to find the previous move of the ticket, which will be the time the ticket entered that stage. Calculating the duration is as simple as subtracting the previous date from the move date. What you should notice is the use of the COALESCE in the previous move date. What that does is that if a ticket doesn’t have a previous move, then it uses the date of creation of the ticket. This takes care of the cases of tickets being created directly into the Doing stage, as it still will properly calculate the time it took to leave the stage. This is the result of the first CTE, showing the time spent in each stage. Notice how the Ticket 2 has two entries, as it visited the Doing stage in two separate occasions. With this done, it’s just a matter of getting the average as the SUM of total days spent in doing, divided by the distinct number of tickets that ever left the stage. Doing it this way, instead of simply using the AVG, makes sure that the two rows for Ticket 2 get properly accounted for as a single ticket. Not so bad, right? The goal of this second challenge is to find the most recent contract sequence of every employee. A break of sequence happens when two contracts have a gap of more than one day between them.  In this dataset, there are no contract overlaps, meaning that a contract for the same employee either has a gap or ends a day before the new one starts. “`SQL CREATE TABLE contracts (     contract_id integer PRIMARY KEY,     employee_id integer NOT NULL,     start_date date NOT NULL,     end_date date NOT NULL ); INSERT INTO contracts (contract_id, employee_id, start_date, end_date) VALUES      — Employee 1: Two continuous contracts     (1, 1, ‘2024-01-01’, ‘2024-03-31’),     (2, 1, ‘2024-04-01’, ‘2024-06-30’),     — Employee 2: One contract, then a gap of three days, then two contracts     (3, 2, ‘2024-01-01’, ‘2024-02-15’),     (4, 2, ‘2024-02-19’, ‘2024-04-30’),     (5, 2, ‘2024-05-01’, ‘2024-07-31’),     — Employee 3: One contract     (6, 3, ‘2024-03-01’, ‘2024-08-31’); “` As a summary of the data: Employee 1: Has two continuous contracts. Employee 2: One contract, then a gap of three days, then two contracts. Employee 3: One contract. The expected result, given the dataset, is that all contracts should be included except for the first contract of Employee 2, which is the only one that has a gap. Before explaining the logic behind the solution, I would like you to think about what operation can be used to join the contracts that belong to the same sequence. Focus only on the second row of data, what information do you need to know if this contract was a break or not? I hope it’s clear that this is the perfect situation for window functions, again. They are incredibly useful for solving problems like this, and understanding when to use them helps a lot in finding clean solutions to problems. First thing to do, then, is to get the end date of the previous contract for the same employee with the LAG function. Doing that, it’s simple to compare both dates and check if it was a break of sequence. “`SQL WITH ordered_contracts AS (     SELECT         *,         LAG(end_date) OVER (PARTITION BY employee_id ORDER BY start_date) AS previous_end_date     FROM         contracts ), gapped_contracts AS (     SELECT         *,         — Deals with the case of the first contract, which won’t have         — a previous end date. In this case, it’s still the start of a new         — sequence.         CASE WHEN previous_end_date IS NULL             OR previous_end_date < start_date – INTERVAL '1 day' THEN             1         ELSE             0         END AS is_new_sequence     FROM         ordered_contracts ) SELECT * FROM gapped_contracts ORDER BY employee_id ASC; “` An intuitive way to continue the query is to number the sequences of each employee. For example, an employee who has no gap, will always be on his first sequence, but an employee who had 5 breaks in contracts will be on his 5th sequence. Funnily enough, this is done by another window function. “`SQL — — Previous CTEs — sequences AS (     SELECT         *,         SUM(is_new_sequence) OVER (PARTITION BY employee_id ORDER BY start_date) AS sequence_id FROM     gapped_contracts ) SELECT * FROM sequences ORDER BY employee_id ASC; “` Notice how, for Employee 2, he starts his sequence #2 after the first gapped value. To finish this query, I grouped the data by employee, got the value of their most recent sequence, and then did an inner join with the sequences to keep only the most recent one. “`SQL — — Previous CTEs — max_sequence AS (     SELECT         employee_id,         MAX(sequence_id) AS max_sequence_id FROM     sequences GROUP BY     employee_id ), latest_contract_sequence AS (     SELECT         c.contract_id,         c.employee_id,         c.start_date,         c.end_date     FROM         sequences c         JOIN max_sequence m ON c.sequence_id = m.max_sequence_id             AND c.employee_id = m.employee_id         ORDER BY             c.employee_id,             c.start_date ) SELECT     * FROM     latest_contract_sequence; “` As expected, our final result is basically our starting query just with the first contract of Employee 2 missing!  Finally, the last puzzle — I’m glad you made it this far.  For me, this is the most mind-blowing one, as when I first encountered this problem I thought of a completely different solution that would be a mess to implement in SQL. For this puzzle, I’ve changed the context from what I had to deal with for my job, as I think it will make it easier to explain.  Imagine you’re a data analyst at an event venue, and you’re analyzing the talks scheduled for an upcoming event. You want to find the time of day where there will be the highest number of talks happening at the same time. This is what you should know about the schedules: Rooms are booked in increments of 30min, e.g. from 9h-10h30. The data is clean, there are no overbookings of meeting rooms. There can be back-to-back meetings in a single meeting room. Meeting schedule visualized (this is the actual data).  “`SQL CREATE TABLE meetings (     room TEXT NOT NULL,     start_time TIMESTAMP NOT NULL,     end_time TIMESTAMP NOT NULL ); INSERT INTO meetings (room, start_time, end_time) VALUES     — Room A meetings     ('Room A', '2024-10-01 09:00', '2024-10-01 10:00'),     ('Room A', '2024-10-01 10:00', '2024-10-01 11:00'),     ('Room A', '2024-10-01 11:00', '2024-10-01 12:00'),     — Room B meetings     ('Room B', '2024-10-01 09:30', '2024-10-01 11:30'),     — Room C meetings     ('Room C', '2024-10-01 09:00', '2024-10-01 10:00'),     ('Room C', '2024-10-01 11:30', '2024-10-01 12:00'); “` The way to solve this is using what is called a Sweep Line Algorithm, or also known as an event-based solution. This last name actually helps to understand what will be done, as the idea is that instead of dealing with intervals, which is what we have in the original data, we deal with events instead. To do this, we need to transform every row into two separate events. The first event will be the Start of the meeting, and the second event will be the End of the meeting. “`SQL WITH events AS (   — Create an event for the start of each meeting (+1)   SELECT      start_time AS event_time,      1 AS delta   FROM meetings   UNION ALL   — Create an event for the end of each meeting (-1)   SELECT     — Small trick to work with the back-to-back meetings (explained later)     end_time – interval '1 minute' as end_time,     -1 AS delta   FROM meetings ) SELECT * FROM events; “` Take the time to understand what is happening here. To create two events from a single row of data, we’re simply unioning the dataset on itself; the first half uses the start time as the timestamp, and the second part uses the end time. You might already notice the delta column created and see where this is going. When an event starts, we count it as +1, when it ends, we count it as -1. You might even be already thinking of another window function to solve this, and you’re actually right! But before that, let me just explain the trick I used in the end dates. As I don’t want back-to-back meetings to count as two concurrent meetings, I’m subtracting a single minute of every end date. This way, if a meeting ends and another starts at 10h30, it won’t be assumed that two meetings are concurrently happening at 10h30. Okay, back to the query and yet another window function. This time, though, the function of choice is a rolling SUM. “`SQL — — Previous CTEs — ordered_events AS (   SELECT     event_time,     delta,     SUM(delta) OVER (ORDER BY event_time, delta DESC) AS concurrent_meetings   FROM events ) SELECT * FROM ordered_events ORDER BY event_time DESC; “` The rolling SUM at the Delta column is essentially walking down every record and finding how many events are active at that time. For example, at 9 am sharp, it sees two events starting, so it marks the number of concurrent meetings as two! When the third meeting starts, the count goes up to three. But when it gets to 9h59 (10 am), then two meetings end, bringing the counter back to one. With this data, the only thing missing is to find when the highest value of concurrent meetings happens. “`SQL — — Previous CTEs — max_events AS (   — Find the maximum concurrent meetings value   SELECT      event_time,      concurrent_meetings,     RANK() OVER (ORDER BY concurrent_meetings DESC) AS rnk   FROM ordered_events ) SELECT event_time, concurrent_meetings FROM max_events WHERE rnk = 1; “` That’s it! The interval of 9h30–10h is the one with the largest number of concurrent meetings, which checks out with the schedule visualization above! This solution looks incredibly simple in my opinion, and it works for so many situations. Every time you are dealing with intervals now, you should think if the query wouldn’t be easier if you thought about it in the perspective of events. But before you move on, and to really nail down this concept, I want to leave you with a bonus challenge, which is also a common application of the Sweep Line Algorithm. I hope you give it a try! Bonus challenge The context for this one is still the same as the last puzzle, but now, instead of trying to find the period when there are most concurrent meetings, the objective is to find bad scheduling. It seems that there are overlaps in the meeting rooms, which need to be listed so it can be fixed ASAP. How would you find out if the same meeting room has two or more meetings booked at the same time? Here are some tips on how to solve it: It’s still the same algorithm. This means you will still do the UNION, but it will look slightly different. You should think in the perspective of each meeting room. You can use this data for the challenge: “`SQL CREATE TABLE meetings_overlap (     room TEXT NOT NULL,     start_time TIMESTAMP NOT NULL,     end_time TIMESTAMP NOT NULL ); INSERT INTO meetings_overlap (room, start_time, end_time) VALUES     — Room A meetings     ('Room A', '2024-10-01 09:00', '2024-10-01 10:00'),     ('Room A', '2024-10-01 10:00', '2024-10-01 11:00'),     ('Room A', '2024-10-01 11:00', '2024-10-01 12:00'),     — Room B meetings     ('Room B', '2024-10-01 09:30', '2024-10-01 11:30'),     — Room C meetings     ('Room C', '2024-10-01 09:00', '2024-10-01 10:00'),     — Overlaps with previous meeting.     ('Room C', '2024-10-01 09:30', '2024-10-01 12:00'); “` If you’re interested in the solution to this puzzle, as well as the rest of the queries, check this GitHub repo. The first takeaway from this blog post is that window functions are overpowered. Ever since I got more comfortable with using them, I feel that my queries have gotten so much simpler and easier to read, and I hope the same happens to you. If you’re interested in learning more about them, you would probably enjoy reading this other blog post I’ve written, where I go over how you can understand and use them effectively. The second takeaway is that these patterns used in the challenges really do happen in many other places. You might need to find sequences of subscriptions, customer retention, or you might need to find overlap of tasks. There are many situations when you will need to use window functions in a very similar fashion to what was done in the puzzles. The third thing I want you to remember is about this solution to using events besides dealing with intervals. I’ve looked at some problems I solved a long time ago that I could’ve used this pattern on to make my life easier, and unfortunately, I didn’t know about it at the time. I really do hope you enjoyed this post and gave a shot to the puzzles yourself. And I’m sure that if you made it this far, you either learned something new about SQL or strengthened your knowledge of window functions!  Thank you so much for reading. If you have questions or just want to get in touch with me, don’t hesitate to contact me at mtrentz.com. All images by the author unless stated otherwise.

There are some Sql patterns that, once you know them, you start seeing them everywhere. The solutions to the puzzles that I will show you today are actually very simple SQL queries, but understanding the concept behind them will surely unlock new solutions to the queries you write on a day-to-day basis.

These challenges are all based on real-world scenarios, as over the past few months I made a point of writing down every puzzle-like query that I had to build. I also encourage you to try them for yourself, so that you can challenge yourself first, which will improve your learning!

All queries to generate the datasets will be provided in a PostgreSQL and DuckDB-friendly syntax, so that you can easily copy and play with them. At the end I will also provide you a link to a GitHub repo containing all the code, as well as the answer to the bonus challenge I will leave for you!

I organized these puzzles in order of increasing difficulty, so, if you find the first ones too easy, at least take a look at the last one, which uses a technique that I truly believe you won’t have seen before.

Okay, let’s get started.

I love this puzzle because of how short and simple the final query is, even though it deals with many edge cases. The data for this challenge shows tickets moving in between Kanban stages, and the objective is to find how long, on average, tickets stay in the Doing stage.

The data contains the ID of the ticket, the date the ticket was created, the date of the move, and the “from” and “to” stages of the move. The stages present are New, Doing, Review, and Done.

Some things you need to know (edge cases):

  • Tickets can move backwards, meaning tickets can go back to the Doing stage.
  • You should not include tickets that are still stuck in the Doing stage, as there is no way to know how long they will stay there for.
  • Tickets are not always created in the New stage.
```SQL

CREATE TABLE ticket_moves (
    ticket_id INT NOT NULL,
    create_date DATE NOT NULL,
    move_date DATE NOT NULL,
    from_stage TEXT NOT NULL,
    to_stage TEXT NOT NULL
);

```
```SQL

INSERT INTO ticket_moves (ticket_id, create_date, move_date, from_stage, to_stage)
    VALUES
        -- Ticket 1: Created in "New", then moves to Doing, Review, Done.
        (1, '2024-09-01', '2024-09-03', 'New', 'Doing'),
        (1, '2024-09-01', '2024-09-07', 'Doing', 'Review'),
        (1, '2024-09-01', '2024-09-10', 'Review', 'Done'),
        -- Ticket 2: Created in "New", then moves: New → Doing → Review → Doing again → Review.
        (2, '2024-09-05', '2024-09-08', 'New', 'Doing'),
        (2, '2024-09-05', '2024-09-12', 'Doing', 'Review'),
        (2, '2024-09-05', '2024-09-15', 'Review', 'Doing'),
        (2, '2024-09-05', '2024-09-20', 'Doing', 'Review'),
        -- Ticket 3: Created in "New", then moves to Doing. (Edge case: no subsequent move from Doing.)
        (3, '2024-09-10', '2024-09-16', 'New', 'Doing'),
        -- Ticket 4: Created already in "Doing", then moves to Review.
        (4, '2024-09-15', '2024-09-22', 'Doing', 'Review');
```

A summary of the data:

  • Ticket 1: Created in the New stage, moves normally to Doing, then Review, and then Done.
  • Ticket 2: Created in New, then moves: New → Doing → Review → Doing again → Review.
  • Ticket 3: Created in New, moves to Doing, but it is still stuck there.
  • Ticket 4: Created in the Doing stage, moves to Review afterward.

It might be a good idea to stop for a bit and think how you would deal with this. Can you find out how long a ticket stays on a single stage?

Honestly, this sounds intimidating at first, and it looks like it will be a nightmare to deal with all the edge cases. Let me show you the full solution to the problem, and then I will explain what is happening afterward.

```SQL

WITH stage_intervals AS (
    SELECT
        ticket_id,
        from_stage,
        move_date 
        - COALESCE(
            LAG(move_date) OVER (
                PARTITION BY ticket_id 
                ORDER BY move_date
            ), 
            create_date
        ) AS days_in_stage
    FROM
        ticket_moves
)
SELECT
    SUM(days_in_stage) / COUNT(DISTINCT ticket_id) as avg_days_in_doing
FROM
    stage_intervals
WHERE
    from_stage = 'Doing';
```

The first CTE uses the LAG function to find the previous move of the ticket, which will be the time the ticket entered that stage. Calculating the duration is as simple as subtracting the previous date from the move date.

What you should notice is the use of the COALESCE in the previous move date. What that does is that if a ticket doesn’t have a previous move, then it uses the date of creation of the ticket. This takes care of the cases of tickets being created directly into the Doing stage, as it still will properly calculate the time it took to leave the stage.

This is the result of the first CTE, showing the time spent in each stage. Notice how the Ticket 2 has two entries, as it visited the Doing stage in two separate occasions.

With this done, it’s just a matter of getting the average as the SUM of total days spent in doing, divided by the distinct number of tickets that ever left the stage. Doing it this way, instead of simply using the AVG, makes sure that the two rows for Ticket 2 get properly accounted for as a single ticket.

Not so bad, right?

The goal of this second challenge is to find the most recent contract sequence of every employee. A break of sequence happens when two contracts have a gap of more than one day between them. 

In this dataset, there are no contract overlaps, meaning that a contract for the same employee either has a gap or ends a day before the new one starts.

```SQL
CREATE TABLE contracts (
    contract_id integer PRIMARY KEY,
    employee_id integer NOT NULL,
    start_date date NOT NULL,
    end_date date NOT NULL
);

INSERT INTO contracts (contract_id, employee_id, start_date, end_date)
VALUES 
    -- Employee 1: Two continuous contracts
    (1, 1, '2024-01-01', '2024-03-31'),
    (2, 1, '2024-04-01', '2024-06-30'),
    -- Employee 2: One contract, then a gap of three days, then two contracts
    (3, 2, '2024-01-01', '2024-02-15'),
    (4, 2, '2024-02-19', '2024-04-30'),
    (5, 2, '2024-05-01', '2024-07-31'),
    -- Employee 3: One contract
    (6, 3, '2024-03-01', '2024-08-31');
```

As a summary of the data:

  • Employee 1: Has two continuous contracts.
  • Employee 2: One contract, then a gap of three days, then two contracts.
  • Employee 3: One contract.

The expected result, given the dataset, is that all contracts should be included except for the first contract of Employee 2, which is the only one that has a gap.

Before explaining the logic behind the solution, I would like you to think about what operation can be used to join the contracts that belong to the same sequence. Focus only on the second row of data, what information do you need to know if this contract was a break or not?

I hope it’s clear that this is the perfect situation for window functions, again. They are incredibly useful for solving problems like this, and understanding when to use them helps a lot in finding clean solutions to problems.

First thing to do, then, is to get the end date of the previous contract for the same employee with the LAG function. Doing that, it’s simple to compare both dates and check if it was a break of sequence.

```SQL
WITH ordered_contracts AS (
    SELECT
        *,
        LAG(end_date) OVER (PARTITION BY employee_id ORDER BY start_date) AS previous_end_date
    FROM
        contracts
),
gapped_contracts AS (
    SELECT
        *,
        -- Deals with the case of the first contract, which won't have
        -- a previous end date. In this case, it's still the start of a new
        -- sequence.
        CASE WHEN previous_end_date IS NULL
            OR previous_end_date < start_date - INTERVAL '1 day' THEN
            1
        ELSE
            0
        END AS is_new_sequence
    FROM
        ordered_contracts
)
SELECT * FROM gapped_contracts ORDER BY employee_id ASC;
```

An intuitive way to continue the query is to number the sequences of each employee. For example, an employee who has no gap, will always be on his first sequence, but an employee who had 5 breaks in contracts will be on his 5th sequence. Funnily enough, this is done by another window function.

```SQL
--
-- Previous CTEs
--
sequences AS (
    SELECT
        *,
        SUM(is_new_sequence) OVER (PARTITION BY employee_id ORDER BY start_date) AS sequence_id
FROM
    gapped_contracts
)
SELECT * FROM sequences ORDER BY employee_id ASC;
```

Notice how, for Employee 2, he starts his sequence #2 after the first gapped value. To finish this query, I grouped the data by employee, got the value of their most recent sequence, and then did an inner join with the sequences to keep only the most recent one.

```SQL
--
-- Previous CTEs
--
max_sequence AS (
    SELECT
        employee_id,
        MAX(sequence_id) AS max_sequence_id
FROM
    sequences
GROUP BY
    employee_id
),
latest_contract_sequence AS (
    SELECT
        c.contract_id,
        c.employee_id,
        c.start_date,
        c.end_date
    FROM
        sequences c
        JOIN max_sequence m ON c.sequence_id = m.max_sequence_id
            AND c.employee_id = m.employee_id
        ORDER BY
            c.employee_id,
            c.start_date
)
SELECT
    *
FROM
    latest_contract_sequence;
```

As expected, our final result is basically our starting query just with the first contract of Employee 2 missing! 

Finally, the last puzzle — I’m glad you made it this far. 

For me, this is the most mind-blowing one, as when I first encountered this problem I thought of a completely different solution that would be a mess to implement in SQL.

For this puzzle, I’ve changed the context from what I had to deal with for my job, as I think it will make it easier to explain. 

Imagine you’re a data analyst at an event venue, and you’re analyzing the talks scheduled for an upcoming event. You want to find the time of day where there will be the highest number of talks happening at the same time.

This is what you should know about the schedules:

  • Rooms are booked in increments of 30min, e.g. from 9h-10h30.
  • The data is clean, there are no overbookings of meeting rooms.
  • There can be back-to-back meetings in a single meeting room.

Meeting schedule visualized (this is the actual data). 

```SQL
CREATE TABLE meetings (
    room TEXT NOT NULL,
    start_time TIMESTAMP NOT NULL,
    end_time TIMESTAMP NOT NULL
);

INSERT INTO meetings (room, start_time, end_time) VALUES
    -- Room A meetings
    ('Room A', '2024-10-01 09:00', '2024-10-01 10:00'),
    ('Room A', '2024-10-01 10:00', '2024-10-01 11:00'),
    ('Room A', '2024-10-01 11:00', '2024-10-01 12:00'),
    -- Room B meetings
    ('Room B', '2024-10-01 09:30', '2024-10-01 11:30'),
    -- Room C meetings
    ('Room C', '2024-10-01 09:00', '2024-10-01 10:00'),
    ('Room C', '2024-10-01 11:30', '2024-10-01 12:00');
```

The way to solve this is using what is called a Sweep Line Algorithm, or also known as an event-based solution. This last name actually helps to understand what will be done, as the idea is that instead of dealing with intervals, which is what we have in the original data, we deal with events instead.

To do this, we need to transform every row into two separate events. The first event will be the Start of the meeting, and the second event will be the End of the meeting.

```SQL
WITH events AS (
  -- Create an event for the start of each meeting (+1)
  SELECT 
    start_time AS event_time, 
    1 AS delta
  FROM meetings
  UNION ALL
  -- Create an event for the end of each meeting (-1)
  SELECT 
   -- Small trick to work with the back-to-back meetings (explained later)
    end_time - interval '1 minute' as end_time,
    -1 AS delta
  FROM meetings
)
SELECT * FROM events;
```

Take the time to understand what is happening here. To create two events from a single row of data, we’re simply unioning the dataset on itself; the first half uses the start time as the timestamp, and the second part uses the end time.

You might already notice the delta column created and see where this is going. When an event starts, we count it as +1, when it ends, we count it as -1. You might even be already thinking of another window function to solve this, and you’re actually right!

But before that, let me just explain the trick I used in the end dates. As I don’t want back-to-back meetings to count as two concurrent meetings, I’m subtracting a single minute of every end date. This way, if a meeting ends and another starts at 10h30, it won’t be assumed that two meetings are concurrently happening at 10h30.

Okay, back to the query and yet another window function. This time, though, the function of choice is a rolling SUM.

```SQL
--
-- Previous CTEs
--
ordered_events AS (
  SELECT
    event_time,
    delta,
    SUM(delta) OVER (ORDER BY event_time, delta DESC) AS concurrent_meetings
  FROM events
)
SELECT * FROM ordered_events ORDER BY event_time DESC;
```

The rolling SUM at the Delta column is essentially walking down every record and finding how many events are active at that time. For example, at 9 am sharp, it sees two events starting, so it marks the number of concurrent meetings as two!

When the third meeting starts, the count goes up to three. But when it gets to 9h59 (10 am), then two meetings end, bringing the counter back to one. With this data, the only thing missing is to find when the highest value of concurrent meetings happens.

```SQL
--
-- Previous CTEs
--
max_events AS (
  -- Find the maximum concurrent meetings value
  SELECT 
    event_time, 
    concurrent_meetings,
    RANK() OVER (ORDER BY concurrent_meetings DESC) AS rnk
  FROM ordered_events
)
SELECT event_time, concurrent_meetings
FROM max_events
WHERE rnk = 1;
```

That’s it! The interval of 9h30–10h is the one with the largest number of concurrent meetings, which checks out with the schedule visualization above!

This solution looks incredibly simple in my opinion, and it works for so many situations. Every time you are dealing with intervals now, you should think if the query wouldn’t be easier if you thought about it in the perspective of events.

But before you move on, and to really nail down this concept, I want to leave you with a bonus challenge, which is also a common application of the Sweep Line Algorithm. I hope you give it a try!

Bonus challenge

The context for this one is still the same as the last puzzle, but now, instead of trying to find the period when there are most concurrent meetings, the objective is to find bad scheduling. It seems that there are overlaps in the meeting rooms, which need to be listed so it can be fixed ASAP.

How would you find out if the same meeting room has two or more meetings booked at the same time? Here are some tips on how to solve it:

  • It’s still the same algorithm.
  • This means you will still do the UNION, but it will look slightly different.
  • You should think in the perspective of each meeting room.

You can use this data for the challenge:

```SQL
CREATE TABLE meetings_overlap (
    room TEXT NOT NULL,
    start_time TIMESTAMP NOT NULL,
    end_time TIMESTAMP NOT NULL
);

INSERT INTO meetings_overlap (room, start_time, end_time) VALUES
    -- Room A meetings
    ('Room A', '2024-10-01 09:00', '2024-10-01 10:00'),
    ('Room A', '2024-10-01 10:00', '2024-10-01 11:00'),
    ('Room A', '2024-10-01 11:00', '2024-10-01 12:00'),
    -- Room B meetings
    ('Room B', '2024-10-01 09:30', '2024-10-01 11:30'),
    -- Room C meetings
    ('Room C', '2024-10-01 09:00', '2024-10-01 10:00'),
    -- Overlaps with previous meeting.
    ('Room C', '2024-10-01 09:30', '2024-10-01 12:00');
```

If you’re interested in the solution to this puzzle, as well as the rest of the queries, check this GitHub repo.

The first takeaway from this blog post is that window functions are overpowered. Ever since I got more comfortable with using them, I feel that my queries have gotten so much simpler and easier to read, and I hope the same happens to you.

If you’re interested in learning more about them, you would probably enjoy reading this other blog post I’ve written, where I go over how you can understand and use them effectively.

The second takeaway is that these patterns used in the challenges really do happen in many other places. You might need to find sequences of subscriptions, customer retention, or you might need to find overlap of tasks. There are many situations when you will need to use window functions in a very similar fashion to what was done in the puzzles.

The third thing I want you to remember is about this solution to using events besides dealing with intervals. I’ve looked at some problems I solved a long time ago that I could’ve used this pattern on to make my life easier, and unfortunately, I didn’t know about it at the time.


I really do hope you enjoyed this post and gave a shot to the puzzles yourself. And I’m sure that if you made it this far, you either learned something new about SQL or strengthened your knowledge of window functions! 

Thank you so much for reading. If you have questions or just want to get in touch with me, don’t hesitate to contact me at mtrentz.com.

All images by the author unless stated otherwise.

Shape
Shape
Stay Ahead

Explore More Insights

Stay ahead with more perspectives on cutting-edge power, infrastructure, energy,  bitcoin and AI solutions. Explore these articles to uncover strategies and insights shaping the future of industries.

Shape

AI inferencing is headed for the network edge

On the chip front, AI edge models run on an advanced type of chip called a neural processing unit or NPU. These chips, such as Google’s Tensor Processing Unit (TPU) or Qualcomm’s Snapdragon, are small, efficient, and don’t use as much energy or create as much heat as traditional CPUs

Read More »

Nvidia will use Palantir to gain insight its supply chain

Nvidia will use Palantir’s Foundry software to analyze its global network of suppliers and partners for supply chain risks — and Palantir will incorporate Nvida’s Nemotron open AI model into its existing AI software stack. The deal will enhance both companies’ offerings, they said: Nvidia will use Palantir’s AI stack

Read More »

YPF taps Axens for new diesel hydrotreater at Argentinian refinery

YPF SA has let a contract to Axens Group to license proprietary technology and provide associated equipment for a new 5,000-cu m/day diesel hydrotreating unit to be installed at one of the Argentine operator’s in-country industrial complexes. As part of the contract announced in September, Axens will deliver the new diesel hydrotreating unit—which will be configured with Prime-D technology—in prefabricated modules, an approach the technology provider said will reduce project execution time by 6 months compared with conventional site construction. The modular design will integrate pressure vessels, structural components, piping, and instrumentation before shipment to the refinery. The approach is intended to limit on-site construction and interference with ongoing refinery operations, Axens said. While Axens confirmed it will execute the project in a way that allows YPF to maintain ongoing operations of the refinery, neither the service provider nor YPF identified which industrial complex will receive the new unit or disclose its capital cost, schedule, or anticipated startup date. Broader fuel-improvement program The new unit comes as part of YPF’s broader program to bring its refining system into compliance with Argentina’s tighter diesel specifications. YPF operates three refineries with combined capacity of 338,000 b/d: La Plata, Luján de Cuyo, and Plaza Huincul. In the operator’s second-quarter 2026 earnings report and accompanying presentation, YPF confirmed completing installation and commissioning in July of its previously announced new hydrotreating unit at the 113,900-b/d Luján de Cuyo refining complex in Mendoza Province, Argentina. In its 2025 annual report published earlier in 2026, YPF said the Luján de Cuyo project also was to include a new hydrogen-generation unit, as well as a revamp of a separate hydrotreating unit at the site. The report identified an estimated $637 million investment for the refinery’s wider fuel-quality program. The annual report also confirmed advanced engineering design for new

Read More »

IEA: Ukrainian drone campaign degrades Russian refining resilience

Increasingly frequent and precise Ukrainian drone attacks are damaging Russian processing units and lengthening repair times, forcing Moscow into unprecedented export bans, relaxed fuel-quality standards, and imports to protect domestic supply, according to the International Energy Agency (IEA). Russia’s 32 major refineries, with 6.5 million b/d of nameplate capacity, make it the world’s third-largest refined-products producer after the US and China. But crude runs fell to 3.8 million b/d in June 2026, down 30% year on year and the lowest since May 2004. Gasoline output is reportedly down about 20%. Ukraine has targeted Russian oil infrastructure since the 2022 full-scale invasion, but IEA said the campaign’s scale, range, and effectiveness increased sharply during 2025-26. A Russian refinery was successfully struck once every 3 days on average in the first 8 months of 2026. Ukrainian forces are now sending multiple drone waves against single sites, overwhelming protective netting and air defenses. Reach has expanded as well. On July 7, Ukraine struck Gazprom Neft PJSC’s 450,000-b/d Omsk refinery, Russia’s largest, some 2,500 km from the border, while several refineries closer to Ukraine have been hit as many as 15 times. By late August, only four major refineries—all in Eastern Siberia or farther east, 3,500-6,500 km from Ukraine—remained untouched. Secondary units targeted Targeting also appears more precise, increasingly hitting secondary units alongside crude distillation units. Fluid catalytic crackers, reformers, and hydrotreaters are critical to light-product yields and fuel specifications. Minor damage to a crude distillation unit can often be repaired in 1-2 weeks, but serious damage to more complex units can require 6-8 months, IEA said. The 250,000-b/d Moscow refinery, heavily damaged in June, is reportedly offline until early 2027. Sanctions are compounding the problem by restricting access to replacement equipment and specialist suppliers. Refiners have tried to preserve throughput by postponing maintenance,

Read More »

BLM Wyoming lease sale generates $82 million, Colorado’s sale fetches $4.7 million

The US Bureau of Land Management (BLM)’s quarterly lease sale in Wyoming Sept. 10 showed a robust $82.4 million in high bids, while its Colorado lease sale pulled in $4.7 million, a fraction of the $35.26 million in revenue generated at the bureau’s last lease sale in the state in June. In Wyoming, BLM leased 99 parcels totaling 114,389 acres, with strong interest and competition in Converse and Campbell Counties in the Powder River basin of northeastern Wyoming. The two counties produced 64% of Wyoming’s crude oil in 2024, with Converse leading at 43.3 million bbl, according to the Wyoming State Geological Survey. BLM’s sales statistics show that of the 17 parcels receiving 10 or more bids during the sale, all but 2 were in Converse and Campbell Counties. Most parcels there fetched over $1000/acre, with one in Converse receiving an $8,000/acre winning bid. In contrast, many other counties saw little competition, with 37,000 acres receiving no bids and 12 parcels, totaling over 16,000 acres, going for the legal minimum of $10/acre. In Colorado, BLM leased 29 parcels totaling 14,212 acres. The bureau offered far more acreage in the two previous sales–leasing 134,173 acres in June and 42,532 acres in September. Details of the Colorado sale were unavailable pending the state’s final review. Federal onshore oil and gas leases extend 10 years or as long as production continues in paying quantities, and they carry a 12.5% royalty rate, with revenues split between the federal government and the state.

Read More »

Energy Secretary Keeps Northwest Coal Generating Plant Online

WASHINGTON—U.S. Secretary of Energy Chris Wright today issued an emergency order to keep affordable, reliable, and secure coal generation in the State of Washington online to help address critical grid reliability issues facing the Northwestern region of the United States. The emergency order directs TransAlta Centralia Generation, LLC (TransAlta) to ensure that Unit 2 of the Centralia Generating Station in Centralia, Washington, a coal-fired power plant, remains available to operate. Centralia Unit 2 was scheduled to shut down at the end of 2025. “America needs more reliable power, not less, and today’s order will help ensure reliable electricity generation remains available to help address periods of peak demand,” said Secretary Wright. “The Trump Administration remains committed to reversing the misguided energy subtraction policies it inherited from past leaders. Instead, we are advancing energy addition and expanding the American people’s access to affordable, reliable, and secure electricity. Similar actions preventing the premature shutdown of reliable power generation have prevented blackouts and likely saved lives.” Thanks to President Trump’s leadership, coal generating plants across the country are being saved from premature retirement. For example, in 2025, more than 17 gigawatts of coal-power electricity generation were saved from going offline.  The availability of Centralia to operate will continue to be an asset to maintain reliability in the Western Electricity Coordinating Council (WECC) Northwest region and is necessary to address elevated reliability risks in the WECC-Northwest region during extreme weather and reduce the risk of power outages that could threaten public health and safety.  As outlined in DOE’s Resource Adequacy Report, premature retirements of reliable generation resources increase the risk of power outages. This order is in effect beginning on September 13, 2026, through December 11, 2026.

Read More »

S&P Global: Middle East crude flows to stay below prewar levels through 2027

Crude markets are settling into a prolonged period in which supply disruption is a standing condition rather than a series of discrete shocks, according to a new analysis from S&P Global Energy. For the first time since the US-Iran war began, the firm no longer expects Middle Eastern crude production to recover to prewar levels by yearend 2027. The outlook assumes no definitive end to the conflict, no normalization of traffic through the Strait of Hormuz, and no removal of Red Sea disruption risk from Iran’s Houthi allies over that period. Middle Eastern crude and condensate exports are now forecast to average roughly 10-16 million b/d on a monthly basis through 2027, compared with about 20 million b/d in January-February 2026, immediately before the war. Regional crude and condensate production is expected to average 21 million b/d over the same period, 4.2 million b/d below S&P Global’s previous projection. Production capacity has not been permanently lost, but security and logistical constraints are limiting how much oil can reach the market, S&P Global said. Gulf producers have strong incentives to find ways to move more oil to market and can be expected to adapt around political and security constraints where possible, said Jim Burkhard, vice-president and global head of crude oil research at S&P Global Energy. The market, however, “is not returning to calm,” Burkhard said. Instead, it is adjusting to conditions defined by unresolved conflict and persistent maritime risk, with oil flows remaining below prewar levels and an uneven path toward recovery. Price outlook S&P Global now expects crude oil prices broadly in an $80-100/bbl range through 2027. Dated Brent is expected to average around $90/bbl or higher for the balance of 2026 and $86/bbl in 2027, $5/bbl above the firm’s previous forecast. Brent recently traded above $100/bbl for the

Read More »

Oil extends rally on further Middle East disruptions

Oil, fundamental analysis Global crude oil prices have now been on a 10-day, +$24.50/bbl rally spurred by increasing military actions on both sides of the Iran war. Furthermore, rebel groups have entered on the side of Iran. Strategic Petroleum Reserves (SPR) inventories declined again while commercial stocks saw a minor draw. Both gasoline and distillate storages showed increases. WTI’s High was Friday’s $104.45/bbl for October while the Low was Tuesday’s $91.80 (markets were closed Monday). October Brent crude also hit its High also on Friday at $109.95/bbl with the low on Monday at $95.95. After running “too high, too fast,” the market retreated on Friday. However, both grades settled considerably higher on the week. The WTI/Brent spread has now widened to $5.35. This week’s prices were the highest in 90 days. Yemen-based Houthi rebels have entered the regional conflict by attacking Saudi Arabian oil infrastructure on the Red Sea. They managed to capture the port city of Mokha and the island of Perim. Perim sits in the middle of the Bab el-Mandab Strait and essentially divides the strait into two distinct shipping lanes. Bab el-Mandab is the gateway to the Gulf of Oman. Blocking the strait would force Saudi oil shipments to move north in the Red Sea to the Mediterranean Sea, a route that would then involve circumnavigating the African continent to get to Asian markets. Saudi oil production for August was down 1.9 million b/d to about 6.0 million b/d. The US Navy hit three Iranian oil tankers, halting their efforts to pass through the Strait of Hormuz. Meanwhile, Iran has struck two vessels near Oman. There has been some talk that certain entities are working with Iran about safe passage arrangements, which is part of the reason for Friday’s lower prices. Meanwhile, at its meeting last Sunday,

Read More »

Nuclear’s Next AI Test: Building at Scale

For data center developers facing multiyear utility interconnection queues and tightening power markets, nuclear energy is entering a different phase of its AI infrastructure story. The near-term opportunity still rests largely with the existing reactor fleet. Holtec International has moved the Palisades Nuclear Plant in Michigan into fuel loading, one of the final major stages before reactor startup activities. Constellation Energy, meanwhile, continues to work toward a 2027 restart of the former Three Mile Island Unit 1, now the Christopher M. Crane Clean Energy Center, under its long-term power agreement with Microsoft. Together, Palisades and Crane represent roughly 1.64 GW of existing nuclear capacity that could return to service without waiting for entirely new plants to be licensed, financed and constructed. That makes reactor restarts one of the few ways nuclear generation can materially intersect with data center power demand before the end of the decade. But the more consequential change may be taking place further upstream. A burst of activity from advanced nuclear developers at the end of August pointed increasingly toward the industrial systems required to move new reactor designs from demonstrations to repeatable infrastructure. X-energy, TerraPower, GE Vernova Hitachi, Oklo, Westinghouse, Kairos Power and others reported progress involving fuel supply, reactor testing, manufacturing, licensing and commercial deployment. None of these advanced reactor projects will solve the industry’s 2027 or 2028 power shortage. That is no longer the most useful test. The more important question is whether advanced nuclear can begin acquiring the characteristics of an industrial supply chain: dependable fuel, standardized manufacturing, repeatable construction, tested reactor systems and enough commercial certainty for large power customers to plan around deployment schedules measured in years rather than speculation. For data center infrastructure, that is the transition worth watching. Palisades Moves From Restoration to Startup The clearest near-term proof point

Read More »

The waste heat paradox: How data centers can cool AI with the heat AI creates

A 40-year-old technology built for this exact moment Absorption chillers produce chilled water the way a conventional chiller does, but they use heat instead of electricity to drive the refrigeration cycle. A generator uses hot water, steam, or exhaust gas to separate refrigerant vapor from a lithium bromide solution; the vapor condenses, evaporates under low pressure to produce the cooling effect, and is reabsorbed to close the loop. Because there’s no large electrically driven compressor, the electrical footprint is small: industry analysis puts absorption chillers at roughly 2 MW of cooling output for just 20–25 kW of electrical input, compared to 500 kW or more of electrical draw for a conventional chiller doing the same job. The technology has existed commercially for decades and never displaced electric chillers at scale, for one simple reason: it needs a steady, moderate-to-high-temperature heat source to run, and building a boiler specifically to feed one erased most of the savings. That missing piece is exactly what two current infrastructure trends are now supplying as a byproduct. Two trends CIOs are already funding that solve the “missing heat” problem 1. On-site power generation is becoming standard, not exceptional Grid interconnection delays in major data center markets now stretch into years, pushing hyperscale operators toward gas turbines, engines, and fuel cells built directly on campus — all of which reject substantial heat as a byproduct of making electricity. Bloom Energy already pairs its fuel-cell systems directly with absorption chillers at data center sites, using exhaust heat to generate chilled water and reduce reliance on the electric chiller plant. Some industry forecasts expect roughly a third of data centers to run fully on-site-powered campuses by 2030 — meaning this heat stream is a permanent feature of the infrastructure roadmap, not a one-off opportunity.

Read More »

DCF Poll: How Should Utilities Vet Real vs. ‘Ghost’ Data Center Demand?

Matt Vincent is Editor in Chief of Data Center Frontier, where he leads editorial strategy and coverage focused on the infrastructure powering cloud computing, artificial intelligence, and the digital economy. A veteran B2B technology journalist with more than two decades of experience, Vincent specializes in the intersection of data centers, power, cooling, and emerging AI-era infrastructure. Since assuming the EIC role in 2023, he has helped guide Data Center Frontier’s coverage of the industry’s transition into the gigawatt-scale AI era, with a focus on hyperscale development, behind-the-meter power strategies, liquid cooling architectures, and the evolving energy demands of high-density compute, while working closely with the Digital Infrastructure Group at Endeavor Business Media to expand the brand’s analytical and multimedia footprint. Vincent also hosts The Data Center Frontier Show podcast, where he interviews industry leaders across hyperscale, colocation, utilities, and the data center supply chain to examine the technologies and business models reshaping digital infrastructure. Since its inception he serves as Head of Content for the Data Center Frontier Trends Summit. Before becoming Editor in Chief, he served in multiple senior editorial roles across Endeavor Business Media’s digital infrastructure portfolio, with coverage spanning data centers and hyperscale infrastructure, structured cabling and networking, telecom and datacom, IP physical security, and wireless and Pro AV markets. He began his career in 2005 within PennWell’s Advanced Technology Division and later held senior editorial positions supporting brands such as Cabling Installation & Maintenance, Lightwave Online, Broadband Technology Report, and Smart Buildings Technology. Vincent is a frequent moderator, interviewer, and keynote speaker at industry events including the HPC Forum, where he delivers forward-looking analysis on how AI and high-performance computing are reshaping digital infrastructure. He graduated with honors from Indiana University Bloomington with a B.A. in English Literature and Creative Writing and lives in southern New Hampshire with

Read More »

Nvidia invests $3.5B in MediaTek to extend its grip on AI

AI infrastructure: MediaTek will work with Nvidia’s NVLink Fusion ecosystem to enable customers to develop custom AI infrastructure designed to integrate with Nvidia rack-scale systems and AI factories. Local AI computing: The companies will continue to collaborate on multiple generations of Nvidia RTX Spark and DGX Spark PC chips, powering consumer PCs, AI developer supercomputers, and enterprise-class workstations, that integrate Nvidia GPUs with MediaTek SoCs. Automotive: MediaTek and Nvidia will continue developing platforms for AI-powered, software-defined vehicles in the era of physical AI.  “MediaTek is one of the world’s great semiconductor companies, with exceptional expertise in system-on-chip design, connectivity, leading performance and power efficiency,” said Jensen Huang, founder and CEO of Nvidia, in a statement. “Together, we’re building platforms that bring Nvidia accelerated computing to new markets and give customers the freedom to create differentiated AI systems at enormous scale.” NVLink is a high-performance interface, but this move also helps lock in customers to the Nvidia platform, since NVLink Fusion is not about to hook up to AMD processors. For MediaTek, the Nvidia investment provides a big pile of cash and access to Nvidia’s infrastructure as it attempts to establish itself as a major supplier of custom data center silicon.

Read More »

AI Puts Fiber on the Critical Path

Fiber Becomes Part of the Build A decade ago, DC Blox might have prioritized land near existing fiber from AT&T, Verizon, Zayo or another established network provider. That calculation is different today. As data center campuses have grown and hyperscalers have become a larger share of the customer base, Wabik said connectivity has increasingly become another construction package associated with the project itself. “If Zayo or Verizon or AT&T just happens to be there close by, that’s a good thing,” he said. “But fiber construction is inherently anymore just part of the construction component.” That changes the site-selection question from Is there fiber nearby? to Can fiber be built here at the scale and diversity the customer requires? For DC Blox, Wabik said that can mean assessing whether sufficient public right-of-way exists to establish three or sometimes four diverse fiber paths into a data center. That distinction is important, as AI workloads push infrastructure into markets where power, land and energy options may be more abundant than established carrier density. The hyperscalers themselves have also become major network builders. Wabik characterized them provocatively as today’s telecom providers, pointing to the scale of terrestrial fiber they commission as well as the growing role of companies such as Amazon, Google and Meta in subsea cable development. The point is less that traditional carriers have disappeared than that hyperscalers increasingly design, commission and control enormous portions of the connectivity required to support their own infrastructure. DC Blox now sees requests for 864-count fiber as routine and, in some cases, 1,728-count cable. That would have been difficult to imagine during an earlier era when a handful of fibers from an established carrier could satisfy a data center’s connectivity requirements. AI-Scale Fiber Gets Physical The scale becomes clearer when the discussion moves from abstract network

Read More »

Power First: AI Data Centers Become Energy Systems

For decades, data centers consumed electricity much like other large commercial customers: power arrived from the utility, while batteries and diesel generators stood behind it to protect the load. AI is starting to break that model. As data center campuses grow toward hundreds of megawatts and, in some cases, gigawatt scale, developers are increasingly taking responsibility for an energy system that once sat largely outside the data center boundary. Natural gas supply, onsite generation, fuel cells, batteries, controls and the behavior of the compute load itself are increasingly becoming parts of the same infrastructure system. That was the central thread running through “Power First: The New Playbook for Delivering AI Data Centers,” an Aug. 4 session at the Data Center Frontier Trends Summit 2026 in Reston, Virginia. Moderated by Fengrong Li, Senior Managing Director at FTI Consulting, the panel brought together Jim Summers, CEO of GPC Infrastructure; Shankar Achanta, EVP and Chief Product and Technology Officer at FuelCell Energy; Judith Judson, Executive Vice President at Calibrant Energy; and Yuval Bachar, Founder and CEO of EdgeCloudLink. The discussion began with the immediate constraint — the grid cannot deliver capacity on the timetable AI developers increasingly require — but quickly moved beyond the familiar concept of “bridge power.” The larger question was what happens when the data center itself becomes an energy system. From Backup Power to Prime Power Behind-the-meter generation is not new. What has changed is its role and scale. “Traditionally, behind-the-meter generation has been for backup and the sizes were smaller,” Achanta said. “But what they’re seeing is the demand for the power is growing rapidly due to the data center load.” Interconnection queues, transmission limitations and equipment supply constraints are pushing onsite generation into what Achanta called the “front seat,” supplying primary power rather than waiting behind the

Read More »

Microsoft will invest $80B in AI data centers in fiscal 2025

And Microsoft isn’t the only one that is ramping up its investments into AI-enabled data centers. Rival cloud service providers are all investing in either upgrading or opening new data centers to capture a larger chunk of business from developers and users of large language models (LLMs).  In a report published in October 2024, Bloomberg Intelligence estimated that demand for generative AI would push Microsoft, AWS, Google, Oracle, Meta, and Apple would between them devote $200 billion to capex in 2025, up from $110 billion in 2023. Microsoft is one of the biggest spenders, followed closely by Google and AWS, Bloomberg Intelligence said. Its estimate of Microsoft’s capital spending on AI, at $62.4 billion for calendar 2025, is lower than Smith’s claim that the company will invest $80 billion in the fiscal year to June 30, 2025. Both figures, though, are way higher than Microsoft’s 2020 capital expenditure of “just” $17.6 billion. The majority of the increased spending is tied to cloud services and the expansion of AI infrastructure needed to provide compute capacity for OpenAI workloads. Separately, last October Amazon CEO Andy Jassy said his company planned total capex spend of $75 billion in 2024 and even more in 2025, with much of it going to AWS, its cloud computing division.

Read More »

John Deere unveils more autonomous farm machines to address skill labor shortage

Join our daily and weekly newsletters for the latest updates and exclusive content on industry-leading AI coverage. Learn More Self-driving tractors might be the path to self-driving cars. John Deere has revealed a new line of autonomous machines and tech across agriculture, construction and commercial landscaping. The Moline, Illinois-based John Deere has been in business for 187 years, yet it’s been a regular as a non-tech company showing off technology at the big tech trade show in Las Vegas and is back at CES 2025 with more autonomous tractors and other vehicles. This is not something we usually cover, but John Deere has a lot of data that is interesting in the big picture of tech. The message from the company is that there aren’t enough skilled farm laborers to do the work that its customers need. It’s been a challenge for most of the last two decades, said Jahmy Hindman, CTO at John Deere, in a briefing. Much of the tech will come this fall and after that. He noted that the average farmer in the U.S. is over 58 and works 12 to 18 hours a day to grow food for us. And he said the American Farm Bureau Federation estimates there are roughly 2.4 million farm jobs that need to be filled annually; and the agricultural work force continues to shrink. (This is my hint to the anti-immigration crowd). John Deere’s autonomous 9RX Tractor. Farmers can oversee it using an app. While each of these industries experiences their own set of challenges, a commonality across all is skilled labor availability. In construction, about 80% percent of contractors struggle to find skilled labor. And in commercial landscaping, 86% of landscaping business owners can’t find labor to fill open positions, he said. “They have to figure out how to do

Read More »

2025 playbook for enterprise AI success, from agents to evals

Join our daily and weekly newsletters for the latest updates and exclusive content on industry-leading AI coverage. Learn More 2025 is poised to be a pivotal year for enterprise AI. The past year has seen rapid innovation, and this year will see the same. This has made it more critical than ever to revisit your AI strategy to stay competitive and create value for your customers. From scaling AI agents to optimizing costs, here are the five critical areas enterprises should prioritize for their AI strategy this year. 1. Agents: the next generation of automation AI agents are no longer theoretical. In 2025, they’re indispensable tools for enterprises looking to streamline operations and enhance customer interactions. Unlike traditional software, agents powered by large language models (LLMs) can make nuanced decisions, navigate complex multi-step tasks, and integrate seamlessly with tools and APIs. At the start of 2024, agents were not ready for prime time, making frustrating mistakes like hallucinating URLs. They started getting better as frontier large language models themselves improved. “Let me put it this way,” said Sam Witteveen, cofounder of Red Dragon, a company that develops agents for companies, and that recently reviewed the 48 agents it built last year. “Interestingly, the ones that we built at the start of the year, a lot of those worked way better at the end of the year just because the models got better.” Witteveen shared this in the video podcast we filmed to discuss these five big trends in detail. Models are getting better and hallucinating less, and they’re also being trained to do agentic tasks. Another feature that the model providers are researching is a way to use the LLM as a judge, and as models get cheaper (something we’ll cover below), companies can use three or more models to

Read More »

OpenAI’s red teaming innovations define new essentials for security leaders in the AI era

Join our daily and weekly newsletters for the latest updates and exclusive content on industry-leading AI coverage. Learn More OpenAI has taken a more aggressive approach to red teaming than its AI competitors, demonstrating its security teams’ advanced capabilities in two areas: multi-step reinforcement and external red teaming. OpenAI recently released two papers that set a new competitive standard for improving the quality, reliability and safety of AI models in these two techniques and more. The first paper, “OpenAI’s Approach to External Red Teaming for AI Models and Systems,” reports that specialized teams outside the company have proven effective in uncovering vulnerabilities that might otherwise have made it into a released model because in-house testing techniques may have missed them. In the second paper, “Diverse and Effective Red Teaming with Auto-Generated Rewards and Multi-Step Reinforcement Learning,” OpenAI introduces an automated framework that relies on iterative reinforcement learning to generate a broad spectrum of novel, wide-ranging attacks. Going all-in on red teaming pays practical, competitive dividends It’s encouraging to see competitive intensity in red teaming growing among AI companies. When Anthropic released its AI red team guidelines in June of last year, it joined AI providers including Google, Microsoft, Nvidia, OpenAI, and even the U.S.’s National Institute of Standards and Technology (NIST), which all had released red teaming frameworks. Investing heavily in red teaming yields tangible benefits for security leaders in any organization. OpenAI’s paper on external red teaming provides a detailed analysis of how the company strives to create specialized external teams that include cybersecurity and subject matter experts. The goal is to see if knowledgeable external teams can defeat models’ security perimeters and find gaps in their security, biases and controls that prompt-based testing couldn’t find. What makes OpenAI’s recent papers noteworthy is how well they define using human-in-the-middle

Read More »