Session

Select AI Funhouse with 23ai

In Oracle Database 23ai, you can write SQL like this:

SELECT AI What are the top 3 best selling products in June 2017;

And you'll get output like:

PRODUCT_NAME TOTAL_SOLD
-------------------- ----------
Summer in India 78
Monks and Nuns 54
Der Helle Kumpel 52

Let's have a Select AI Funhouse - join me for an hour of just throwing prompts at Select AI. Can we together find out how to phrase prompts to create advanced SQL? Can we make it use analytic functions? Row pattern matching? Pivoting?

This'll be unprepared and interactive - you'll supply the prompts, I'll work the keyboard. Let's see if we can figure out whether the above made the AI execute this:

SELECT P.NAME AS PRODUCT_NAME, SUM(MS.QTY) AS TOTAL_SOLD
FROM PRACTICAL.MONTHLY_SALES MS
JOIN PRACTICAL.PRODUCTS P ON MS.PRODUCT_ID = P.ID
WHERE TO_CHAR(MS.MTH, 'YYYY-MM') = '2017-06'
GROUP BY P.NAME
ORDER BY TOTAL_SOLD DESC
FETCH FIRST 3 ROWS ONLY;

Or this:

SELECT p.NAME AS product_name, SUM(o.QTY) AS total_sold
FROM PRACTICAL.ORDERS ord
JOIN PRACTICAL.ORDERLINES o ON ord.ID = o.ORDER_ID
JOIN PRACTICAL.PRODUCTS p ON o.PRODUCT_ID = p.ID
WHERE TO_CHAR(ord.ORDERED, 'YYYY-MM') = '2017-06'
GROUP BY p.NAME
ORDER BY total_sold DESC
FETCH FIRST 3 ROWS ONLY;

Presented at:
- ODTUG Kscope 2024
- POUG 2024

Kim Berg Hansen

Lead Software Developer, Cegal Danmark A/S | #Oracle #SQL #PLSQL #SYM42

Middelfart, Denmark

Actions

Please note that Sessionize is not responsible for the accuracy or validity of the data provided by speakers. If you suspect this profile to be fake or spam, please let us know.

Jump to top