← Back to SO₂ Calculator
1

Open Custom Queries in Amphora

From the Amphora menu bar, go to Data → Custom Query. The Custom Query panel will open, showing any queries you've previously saved.

2

Create a new query

Click the New Record button in the toolbar above the query list. Give the query a name you'll recognize — for example:

SO2 Calculator Export

3

Paste in the SQL

Copy the query below and paste it into the query body field. It selects the most recent SO₂ measurement per vessel, paired with each vessel's current volume, and outputs exactly the columns the calculator expects.

Amphora Custom Query — SQL
SELECT vessel, volume, pH, current_free_so2
FROM (
    SELECT
        CONTAINER                AS vessel,
        PH                       AS pH,
        FREE_SO2                 AS current_free_so2,
        (SELECT QUANTITY
         FROM CONTAINER_STATUS
         WHERE CONTAINER_STATUS.NAME = CONTAINER) AS volume,
        ROW_NUMBER() OVER (PARTITION BY CONTAINER
                           ORDER BY DATE DESC) AS rn
    FROM MEASUREMENTS
) t
WHERE rn = 1
  AND volume > 0;

Save the query using the Save button or equivalent in your Amphora version.

4

Run the query and verify results

With the query selected, click Execute. Amphora will display the results in a table — one row per vessel. Verify that each row has a vessel name, a positive volume, a pH in a reasonable range (2.8–4.2), and a Free SO₂ value in mg/L.

Vessels with no SO₂ measurement on record, or with zero volume, will not appear — this is expected.

5

Export to Excel

From the results table toolbar, click Export to Excel (or Export to Spreadsheet). Save the file somewhere convenient — your desktop or a shared winery folder.

The calculator accepts .xlsx, .xls, and .csv files.

6

Upload to the calculator

On the SO₂ Calculator, set your target molecular SO₂, pH, and addition compound in Steps 1–3, then scroll to Step 4 — Batch Work Order. Click the upload zone or drag your exported file onto it.

The calculator will generate a work order table with the required addition for each vessel. Click Print Work Order to produce a printable page for the cellar hand.


Column Reference

The query outputs these column names, which the calculator recognizes automatically. No renaming is needed.

Column Required Description
vessel Required Container name — appears as the row label in the work order
volume Required Current volume. Make sure the unit toggle in the calculator (gallons or liters) matches what Amphora stores in CONTAINER_STATUS.QUANTITY
pH Optional Per-vessel pH. If present, the calculator uses each vessel's own pH rather than the global pH entered in Step 1. Leave blank for a vessel to fall back to the global value
current_free_so2 Optional Per-vessel Free SO₂ in mg/L. If present, overrides the global current Free SO₂ from Step 2 of the calculator

Notes & Caveats