JokBoy <andrew.lind...@westnet.com.au> wrote: > Basically, I would like to be able to query one table based on > criteria entered into another table. > > I have attached an excel file with a couple of hours of monitoring > data, the 10 minute data has been interpolated to give minute answers > (as MOEData Tab in the excel sheet). > > This Table of Data would be called MOEData in the database (original I > know...) > > I then would like to have another table (See Criteria Table Tab in > excel sheet). This table would provide the criteria to be used. A > verbose description of the actual query would be as follows (when > looking at the first line of the table). > > Count all the rows between 0:00 and 1:20 on the 16/06/2009, where the > MOEData.Hs is greater than 1.3, OR the (MOEData.Vwind > 20 AND > (Twind is between 45 and 135, or Twind is between 225 and 315))
select Start_Time, End_Time, count(*) as "Above Criteria" from Criteria c join MOEData d on ( d.Date between c.Start_Time and c.End_Time and (d.HsSea > c.Hs_crit or (d.Vwind > c.Vwind_crit and (d.Twind between 45 and 135 or d.Twind between 225 and 315) ) ) ) group by c.rowid; Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users