IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 11, 2026, 3:09:36 PM (2 months ago)
Author:
eugene
Message:

fix various SQL errors caught by more strict mysql versions, especially: force SQL to select a specific entry from non-aggregated fields when other fields are aggregated using e.g., GROUP BY

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-pstamp-20260421/ippTools/share/addtool_checkminidvodbaddrun.sql

    r39528 r43014  
    11-- this selects the minidvodbs that have complete addRuns
    2 SELECT minidvodb_id, minidvodb_name, minidvodb_path, state, minidbg
    3 AS minidvodb_group, (cnt - cnt2) as not_full, cnt as addRun_count
     2SELECT
     3  minidvodb_id,
     4  minidvodb_name,
     5  minidvodb_path,
     6  state,
     7  minidbg AS minidvodb_group,
     8  (cnt - cnt2) as not_full,
     9  cnt as addRun_count
    410FROM minidvodbRun
    5 JOIN
    6    (SELECT minidvodb_name, count(state) as cnt2, cnt, minidbg, minidbn
    7    FROM addRun LEFT JOIN
    8        -- this select grabs (and counts) all the addRuns with any state
    9        -- and groups them by the name
    10        (SELECT minidvodb_group as minidbg, minidvodb_name as minidbn, count(state)
    11         AS cnt
    12         FROM addRun where minidvodb_group = '%s'
    13         GROUP BY minidvodb_name )
    14    AS foo1 ON minidvodb_name = minidbn
    15         -- the second select grabs and counts all the addRuns with state
    16         -- of 'full'         
    17    WHERE addRun.state = 'full' and minidvodb_group = '%s'
    18    GROUP BY minidvodb_name )
     11JOIN (
     12  SELECT
     13    minidvodb_name,
     14    count(state) AS cnt2,
     15    MIN(cnt)     AS cnt,
     16    MIN(minidbg) AS minidbg,
     17    minidbn
     18  FROM addRun
     19  LEFT JOIN (
     20    -- this select grabs (and counts) all the addRuns with any state
     21    -- and groups them by the name
     22    SELECT
     23      MIN(minidvodb_group) AS minidbg,
     24      minidvodb_name AS minidbn,
     25      count(state) AS cnt
     26    FROM addRun
     27    WHERE minidvodb_group = '%s'
     28    GROUP BY minidvodb_name
     29  )
     30  AS foo1
     31  ON minidvodb_name = minidbn
     32  -- the outer select grabs and counts all the addRuns with state
     33  -- of 'full'         
     34  WHERE addRun.state = 'full'
     35  AND minidvodb_group = '%s'
     36  GROUP BY
     37  minidvodb_name
     38)
    1939AS foo2
    2040USING(minidvodb_name)
Note: See TracChangeset for help on using the changeset viewer.