Generating application code is cool and all. However, there are more people out there trying to answer business questions than building apps. So having an LLM that can produce good SQL, and having a pathway to running it (MCP) will be an invaluable asset to any organization!
I don’t recommend or endorse this particular LLM (Opus 4.1), but I mentioned the name so you have a point of reference. I find most LLMs are quite good at generating SQL, or even better, generating Oracle’s SQL dialect. But you WILL find measurable differences between the various LLM offerings, so be alert and picky!
I toured my NETFLIX streaming data a few years ago. I’m wondering what my Agent could extract from that data if I let IT decide to run the SQL. So let’s see β
the order
I am the head of a household, a family of 4 people. My NETFLIX streaming history is stored in my Oracle Autonomous database, in a table called, NETFLIX.
I need a report for each family member, highlighting their viewing habits. Items of interest include titles that have been viewed repeatedly, total time spent watching content, and any patterns you might be able to determine.
How do I make it happen
I’ve exported my personal NETFLIX data and put it into the 19c Always Free Autonomous Database. I have access to this database via my SQLcl MCP Server, and I have configured this MCP Server for my Agent. The agent doesn’t matter, but it rhymes with Todd.
Note: I have used a limited database user to store and query this data, I have definitely NOT used ADMIN for this task.
What’s the plan? Sorry, what’s wrong Todd’s plan?
- get NETFLIX table structure
- take a sample of the data
- get a list of different family members and their viewing statistics
- get total viewing time per family member
- find the top recurring titles for each family member
- Analyze viewing patterns by day of the week and time of day
- analyze content type preferences
- Binge-watch episode ID
I’ll dive into the SQL it produces (because it’s interesting!) later in this post, but let’s get straight to the findings. Note I have anonymized the names of my family members. I’m Jefferson, miss Jeff/el Jefe.
The result
Number of Views
14.4K
Joint Session
Unique Title
7.6K
Shows & Movies
Watch Time
4,891
Number of Hours
Family members
5
Active Profile
π₯ Most Rewatched
GO! Unforgettable Party
42 times
Grey’s Anatomy (97 binge sessions!)
16 eps/day
My Little Pony: Rainbow Rock
29 times
Peak Times
23.00 β 00.00
π₯ Top Rewatches
Total Withdrawal
10 times
West Wing
29 parties
Avengers: Infinity War
9 times
π Diverse Interests
The Great British Baking Show
25+ views
formula 1
13 parties
Selling Twilight
13 parties
Favorite Day
Mon, Thu, Fri
π Favorite Series
Inland areas
31 parties
Virgin River
14 parties
Hart of Dixie
11 parties
Favorite Day
Saturday, Tuesday, Wednesday
π― Favorite Content
LEGO Jurassic World
18 times
We’re Naked Bears
19 parties
Minecraft: Story Mode
24+ views
π Family Key Insights
π Family Superlatives
- Most Active: That Girl (5,630 sessions)
- Most Diverse: Mamacita (2,276 titles)
- Longest Session: Jefferson (30.7 minutes)
- Party Champion: That girl (30 eps/day!)
- Night Owl: Mamacita (peak at 02.00)
π¨βπ©βπ§βπ¦ Shared Interests
- Grey’s Anatomy: Girl & Mamacita
- My Babysitter Is a Vampire: Girl & Boy
- Good Place: Mother-in-Law & Mamacita
- Peak family viewing: 23.00 β 02.00
- Weekend afternoons: The Boy’s domain
π Recommendations
- Jefferson opts for family movie night
- Monitor late night streaming quality
- Download the featurette for a short session of The Boy
- Set a βContinue Watchingβ list.
- Consider a group viewing schedule
Let’s be the judge
Anthropic released Opus 4.1 4 months ago. I am relatively satisfied with the work he did for my assignment.
If I want to review the SQL it is executing, I can do so easily by looking at my MCP log table, DBTOOLS$MCP_LOG.

Let’s look at one of the more interesting questions, ‘ID binge watching sessionβ¦’
The query uses a three (3) level CTE (Common Table Expression) structure with a WITH clause to progressively aggregate and filter data.
NETFLIX Table (raw data)
β
daily_show_views (profile + date + event aggregation)
β
binge_stats (profile + event summary)
β
Final results (top 5 rankings per profile)
There was no problem navigating the INTERVAL column in my table and using the EXTRACT function to get the desired time measurement.
Regular expressions are less fun for me, but there’s no problem using them to handle quotes in show/movie titles, and all the calculations look ‘correct’.
-- Identify binge-watching sessions (multiple episodes of same show in one day)
WITH /* LLM in use is claude-opus-4-1-20250805 */ daily_show_views AS (
SELECT
profile_name,
TRUNC(start_time) as view_date,
REGEXP_SUBSTR(title, '^[^:]+') as show_name,
COUNT(*) as episodes_watched,
SUM(EXTRACT(DAY FROM duration_interval) * 24 * 60 +
EXTRACT(HOUR FROM duration_interval) * 60 +
EXTRACT(MINUTE FROM duration_interval) +
EXTRACT(SECOND FROM duration_interval) / 60) as total_minutes
FROM NETFLIX
WHERE profile_name IS NOT NULL
AND title LIKE '%Season%Episode%'
AND duration_interval IS NOT NULL
GROUP BY profile_name, TRUNC(start_time), REGEXP_SUBSTR(title, '^[^:]+')
HAVING COUNT(*) >= 3 -- 3 or more episodes = binge session
),
binge_stats AS (
SELECT
profile_name,
show_name,
COUNT(*) as binge_sessions,
MAX(episodes_watched) as max_episodes_in_day,
ROUND(AVG(total_minutes), 2) as avg_binge_minutes
FROM daily_show_views
GROUP BY profile_name, show_name
)
SELECT * FROM (
SELECT
profile_name,
show_name,
binge_sessions,
max_episodes_in_day,
avg_binge_minutes,
ROW_NUMBER() OVER (PARTITION BY profile_name ORDER BY binge_sessions DESC, max_episodes_in_day DESC) as rn
FROM binge_stats
)
WHERE rn <= 5
ORDER BY profile_name, binge_sessions DESC
Could this question be better?
For readability perhaps we could move the regex so it’s not called more than once, but I don’t think that would affect the execution plan. I think that’s OK, or at least I think the findings are accurate.
LLM is pretty good at generating SQL! Especially when they have the information they need to do so. The MCP server gives it access to the database and the ability to interrogate the dictionary to obtain table definitions and can sample data. That definitely helps.
CTEs are very popular, especially in the SQL Server world. I wouldn’t be surprised to see an LLM producing SQL that employs them. I also find it easier to read and understand, so I’m fine with that.
As always, supervise your Agent. Review and approve/deny their requests as needed. See how they answer your questions. I do see them make bad assumptions, but often enough that it’s still dangerous. But for this session, the fight was pretty much 1,000.
Berita Terkini
Berita Terbaru
Daftar Terbaru
News
Berita Terbaru
Flash News
RuangJP
Pemilu
Berita Terkini
Prediksi Bola
Togel Deposit Pulsa
Technology
Otomotif
Berita Terbaru
Daftar Judi Slot Online Terpercaya
Slot yang lagi gacor
Teknologi
Berita terkini
Berita Pemilu
Berita Teknologi
Hiburan
master Slote
Berita Terkini
Pendidikan
Resep
Jasa Backlink
One Piece Terbaru