Index: trunk/ippTools/share/pxadmin_create_tables.sql
===================================================================
--- trunk/ippTools/share/pxadmin_create_tables.sql	(revision 27518)
+++ trunk/ippTools/share/pxadmin_create_tables.sql	(revision 27546)
@@ -1536,4 +1536,52 @@
 
 
+-- Tables for static sky analysis
+
+-- A static sky analysis set
+CREATE TABLE staticskyRun (
+      ss_id BIGINT AUTO_INCREMENT, -- unique identifier
+      state VARCHAR(64) NOT NULL,  -- state of run (new, full, etc.)
+      workdir VARCHAR(255) NOT NULL, -- working directory
+      label VARCHAR(64),             -- processing label
+      data_group VARCHAR(64),        -- group for data
+      dist_group VARCHAR(64),        -- group for distribution
+      reduction VARCHAR(64),         -- reduction class (for altering recipe)
+      note VARCHAR(255),             -- note
+      registered TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- time run was registered
+      PRIMARY KEY(dqstats_id),
+      KEY(state),
+      KEY(label),
+      KEY(data_group),
+      KEY(dist_group)
+) ENGINE=innodb DEFAULT CHARSET=latin1;
+
+-- Inputs for static sky analysis
+CREATE TABLE staticskyInput (
+      ss_id BIGINT,             -- static sky identifier
+      stack_id BIGINT,          -- stack identifier
+      PRIMARY KEY(ss_id,stack_id),
+      KEY(stack_id),
+      FOREIGN KEY(ss_id) REFERENCES staticskyRun(ss_id),
+      FOREIGN KEY(stack_id) REFERENCES stackSumSkyfile(stack_id)
+) ENGINE=innodb DEFAULT CHARSET=latin1;
+
+-- Result of static sky analysis
+CREATE TABLE staticskyResult (
+      ss_id BIGINT,             -- static sky identifier
+      path_base VARCHAR(255) NOT NULL, -- root name for outputs
+      dtime_phot FLOAT,                -- elapsed time for photometry
+      dtime_script FLOAT,              -- elapsed time for script
+      sources INT,                     -- number of sources
+      hostname VARCHAR(64) NOT NULL,   -- host that executed script
+      good_frac FLOAT,                 -- good fraction of skycell
+      quality SMALLINT NOT NULL,       -- bad quality flag
+      fault SMALLINT NOT NULL,         -- fault code
+      PRIMARY KEY(ss_id),
+      KEY(good_frac),
+      KEY(fault),
+      KEY(quality),
+      FOREIGN KEY(ss_id) REFERENCES staticskyRun(ss_id),
+) ENGINE=innodb DEFAULT CHARSET=latin1;
+
 -- This comment line is here to avoid empty query error.
 -- Another way to avoid that problem is to omit the semicolon above but I think that is untidy.
Index: trunk/ippTools/share/staticskytool_definebyquery.sql
===================================================================
--- trunk/ippTools/share/staticskytool_definebyquery.sql	(revision 27546)
+++ trunk/ippTools/share/staticskytool_definebyquery.sql	(revision 27546)
@@ -0,0 +1,14 @@
+SELECT
+    tess_id,
+    skycell_id,
+    COUNT(*) AS num,
+    COUNT(DISTINCT filter) AS num_filter
+FROM stackRun
+JOIN stackSumSkyfile USING(stack_id)
+WHERE stackRun.state = 'full'
+    AND stackSumSkyfile.fault = 0
+    AND stackSumSkyfile.quality = 0
+-- WHERE hook %s
+GROUP BY
+    tess_id,
+    skycell_id
