[sqlite] Passing Value from one query to another

2010-02-06 Thread sub sk79
Hi, Here is a version written in PL/SQL using StepSqlite (https://www.metatranz.com/stepsqlite). Perhaps it would be closest to what you expect: note how the variable kwhcost is directly used in second query and also the StepSqlite built-in date operators to simplify the query. 1. Compile the cod

Re: [sqlite] Passing Value from one query to another

2010-02-06 Thread Edzard Pasma
Op 6-feb-2010, om 18:03 heeft Eric Bohlman het volgende geschreven: > BareFeet wrote: >> In general, I think it's much better (performance and logic) to do >> all you can in SQL, without passing values out of SQL results, into >> your non-SQL code, then re-injecting back into another SQL query et

Re: [sqlite] Passing Value from one query to another

2010-02-06 Thread Eric Bohlman
BareFeet wrote: > In general, I think it's much better (performance and logic) to do > all you can in SQL, without passing values out of SQL results, into > your non-SQL code, then re-injecting back into another SQL query etc. With SQLite, that's not really going to make a difference. Since it's a

Re: [sqlite] Passing Value from one query to another

2010-02-06 Thread BareFeet
In general, I think it's much better (performance and logic) to do all you can in SQL, without passing values out of SQL results, into your non-SQL code, then re-injecting back into another SQL query etc. Having said that, I'm not quite sure why you are doing what you're doing, so I can't attemp

Re: [sqlite] Passing Value from one query to another

2010-02-06 Thread Igor Tandetnik
personalt wrote: > I read that page last night.. That sounded like what I wanted to do but I > had no idea how to get my simple query to be a parameterized query. That > is really what I was looking for help on. > > select kwhcost1 from applications; > > SELECT monitordata_hourly.deviceaddre

Re: [sqlite] Passing Value from one query to another

2010-02-06 Thread personalt
I read that page last night.. That sounded like what I wanted to do but I had no idea how to get my simple query to be a parameterized query. That is really what I was looking for help on. select kwhcost1 from applications; SELECT monitordata_hourly.deviceaddress, Round(Sum(monitordata_hou

Re: [sqlite] Passing Value from one query to another

2010-02-06 Thread Igor Tandetnik
personalt wrote: > Is there a way to inside a large sql statement to store a intermediate value > which could be used later in that query? Yes - by using a subquery, as you were shown. Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.or

Re: [sqlite] Passing Value from one query to another

2010-02-06 Thread personalt
I was looking to store this whole query inside a view and just query the view from outside sqlite. Is there a way to inside a large sql statement to store a intermediate value which could be used later in that query? Simon Slavin-3 wrote: > > > On 6 Feb 2010, at 1:54pm, personalt wrote: > >

Re: [sqlite] Passing Value from one query to another

2010-02-06 Thread Igor Tandetnik
personalt wrote: > 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 Read about parameterized queries: http://www.sqlit

Re: [sqlite] Passing Value from one query to another

2010-02-06 Thread Tom Holden
Store the results of the first query in a temporary table? - Original Message - From: "personalt" To: Sent: Saturday, February 06, 2010 8:54 AM Subject: Re: [sqlite] Passing Value from one query to another > > I realize this works fine for this query but is there a w

Re: [sqlite] Passing Value from one query to another

2010-02-06 Thread Simon Slavin
On 6 Feb 2010, at 1:54pm, personalt wrote: > 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 Yes, you use whatever p

Re: [sqlite] Passing Value from one query to another

2010-02-06 Thread personalt
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: > >>

Re: [sqlite] Passing Value from one query to another

2010-02-06 Thread BareFeet
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 app

[sqlite] Passing Value from one query to another

2010-02-06 Thread personalt
I have a query the calcuates number of KWH and the cost of energy used in the last 30 days. Right now the cost per KWH is hardcoded in the 2nd query at .19. What I really want to do is get the value from 'select kwhcost1 from applications;' store that as a variable/paramter and pass it into th