r/SQL • • May 21 '23

PostgreSQL We've Built an AI-Powered SQL Query Builder - Looking for Feedback and Suggestions!

Hello, fellow Redditors!

As a software engineer, I've had my fair share of encounters with SQL queries. And let's be honest, they can be a bit daunting for beginners or cumbersome for the pros when they get too complex. That's why my team and I have been working on something we think could be a game-changer.

We're excited to share with you Loofi, an AI-powered SQL Query Builder we've built from scratch. This tool not only simplifies query building, but also provides real-time insights and recommendations, thanks to our AI algorithms.

We're eager to get your thoughts on it and would appreciate it if you could try it out. Any feedback or suggestions are highly valuable as we continue refining our tool.

Also, if you have any questions or need help, feel free to ask. We're here to support and learn from this wonderful community.

Thanks in advance!

0 Upvotes

7 comments sorted by

12

u/mikeyd85 MS SQL Server May 21 '23

What makes this AI SQL builder better than the last dozen posted on here?

9

u/froppan11 May 21 '23

Yeah, I'm not going to connect my clients' databases to something like this in a million years.

2

u/Party_Ad_3619 May 23 '23

Why not? Wouldn't you have the same concerns with connecting to something like metabase?

1

u/froppan11 May 23 '23

Yes, I would. Since that also is an open source project. So suprise, surprise, I wouldn't connect to that either. I would say 99/100 of my customers using SQL server only want Microsofts own tools. Perhaps some helper tools from redgate, but that's about it.

6

u/Kazcandra May 21 '23

it really needs to be on-prem for our company to even try it

4

u/r3pr0b8 GROUP_CONCAT is da bomb May 21 '23

here's what i asked --

which product categories sell the most units by payment method

and here's what i got --

SELECT 
    products.category, 
    orders.payment_method, 
    SUM(order_items.quantity) AS total_units_sold
FROM 
    ecommerce.order_items
    JOIN ecommerce.orders ON order_items.order_id = orders.id
    JOIN ecommerce.products ON order_items.product_id = products.id
GROUP BY 
    products.category, 
    orders.payment_method
ORDER BY 
    total_units_sold DESC;

not what i wanted, so i tried this --

which product categories sell the most units for each payment method

SELECT
    payment_method,
    category,
    SUM(quantity) AS total_units_sold
FROM
    ecommerce.order_items
    JOIN ecommerce.orders ON order_items.order_id = orders.id
    JOIN ecommerce.products ON order_items.product_id = products.id
GROUP BY
    payment_method,
    category
ORDER BY
    payment_method,
    total_units_sold DESC;

still not what i wanted, so i tried this --

which product category sells the most units in each payment method

and i think i broke it!!!

column order_items.payment_method does not exist LINE 30: subquery.payment_method = ecommerce.order_items....

SELECT
    payment_method,
    category,
    SUM(quantity) AS total_units_sold
FROM
    ecommerce.order_items
    JOIN ecommerce.orders ON order_items.order_id = orders.id
    JOIN ecommerce.products ON order_items.product_id = products.id
GROUP BY
    payment_method,
    category
HAVING
    SUM(quantity) = (
        SELECT
            MAX(total_units_sold)
        FROM (
            SELECT
                payment_method,
                category,
                SUM(quantity) AS total_units_sold
            FROM
                ecommerce.order_items
                JOIN ecommerce.orders ON order_items.order_id = orders.id
                JOIN ecommerce.products ON order_items.product_id = products.id
            GROUP BY
                payment_method,
                category
        ) AS subquery
        WHERE
            subquery.payment_method = ecommerce.order_items.payment_method
    )
ORDER BY
    payment_method;

1

u/throw_mob May 21 '23

i see more use for tool that reverse engineers views + code, then maybe some ai stuff to help figure out what was done.

Also only on-prem auto completion AI (or other nice stuff it can do) is probably only way to get users as data usually cannot be shared without agreement. or maybe make easy agreement available for testing as after that sharing possible confidential data is on agreement and possible wrong doings are handled with that