I realize this works fine for this query but is there a way to to do this by passing the results from one query to the second? I have some more complex calculations coming up where I think this would be an easier way to go
BareFeet wrote: > > On 06/02/2010, at 10:07 PM, personalt wrote: > >> I am just looking to pass a value from one query into a second. Is >> that possible? Can I modify the query below to get the two queries to >> work >> together so that the .19 is repalce by the kwhcost1 from the first query? >> >> select kwhcost1 from applications; >> >> SELECT monitordata_hourly.deviceaddress, >> Round(Sum(monitordata_hourly.ch1kwh),3) AS SumOfch1kwh, >> Round(Sum(monitordata_hourly.ch1kwh),3)*.19 AS SumOfch1kwh_cost >> FROM monitordata_hourly >> Where monitordata_hourly.deviceaddress=142265 and >> (datetime(monitordata_hourly.date))>=datetime('now', 'localtime', '-30 >> days') >> Group by monitordata_hourly.deviceaddress > > Simply enter your first query as a "subquery" in the second, like this: > > SELECT monitordata_hourly.deviceaddress, > Round(Sum(monitordata_hourly.ch1kwh),3) AS SumOfch1kwh, > Round(Sum(monitordata_hourly.ch1kwh),3)*(select kwhcost1 from > applications) AS SumOfch1kwh_cost > FROM monitordata_hourly > Where monitordata_hourly.deviceaddress=142265 and > (datetime(monitordata_hourly.date))>=datetime('now', 'localtime', '-30 > days') > Group by monitordata_hourly.deviceaddress > > Tom > BareFeet > > -- > Comparison of SQLite GUI tools: > http://www.tandb.com.au/sqlite/compare/?ml > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > -- View this message in context: http://old.nabble.com/Passing-Value-from-one-query-to-another-tp27478736p27479816.html Sent from the SQLite mailing list archive at Nabble.com. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users