SQL Joins + Plot

In this example we ask VerbaGPT a plotting question that requires a non-trivial SQL query.

Video of VerbaGPT in action:

User question: Give me a bar plot of sales, by album, of U2

VerbaGPT response:

Cost of query: $0.00*

* Using open-source llama4-maverick model from OpenRouter

Answer:

VerbaGPT identified the correct database (“Chinook”), identified relevant tables, performed the necessary joins and answered the question correctly.

Side note: ‘All That You Can’t Leave Behind’ doesn’t deserve to be last on this plot…

Detailed VerbaGPT read-out window & (editable) code:

In addition to producing the chart, VerbaGPT also provides the user with the following (editable) code. If the user chooses to, they can edit the code before hitting execute button, or simply hit execute without editing the code to produce the image shown above.

import matplotlib.pyplot as plt
import pandas as pd

query = """
SELECT al.Title, SUM(il.Quantity) AS Sales
FROM Album al
JOIN Artist ar ON al.ArtistId = ar.ArtistId
JOIN Track t ON t.AlbumId = al.AlbumId
JOIN InvoiceLine il ON il.TrackId = t.TrackId
WHERE ar.Name = 'U2'
GROUP BY al.Title
ORDER BY Sales DESC;
"""

df = pd.read_sql_query(query, conn)
df.plot.bar(x='Title', y='Sales', rot=90)
plt.show()

Posted

in

,

by

Comments

2 responses to “SQL Joins + Plot”

  1. Guðrún Björg Avatar

    Hello VerbaGPT team. I have a plotting question for zonal temperature changes:

    Since we’re in an El Nino year, can we use VerbaGPT for variations in sea temperatures from say, 1979 to date?

    Example: https://www.cpc.ncep.noaa.gov/data/indices/z500t

    1. VerbaGPT team Avatar

      VerbaGPT is a general-purpose data analytic tool, that you can ask questions of in plain english. If you have your temperature data in a microsoft SQL server or csv file, you can point VerbaGPT to it and ask it to plot the variable of interest.

Leave a Reply

Your email address will not be published. Required fields are marked *