You are basically trying to group values where the individual values are different but each in itself accumulated in stead of
accumulated for the grouping.
Just move the scope of the grouping and use Nulls in stead of 0's, like this:
SELECT stats.which_year AS year,
SUM(CASE WHEN stats.which_mo
On 12/21/2013 10:30 AM, RSmith wrote:
Just move the scope of the grouping and use Nulls in stead of 0's, like
this:
SELECT stats.which_year AS year,
SUM(CASE WHEN stats.which_month = 1 THEN stats.quantity ELSE NULL END) AS
gen,
SUM(CASE WHEN stats.which_month = 2 THEN stats.quantity ELSE NUL
On Sat, 21 Dec 2013 17:30:50 +0200
RSmith wrote:
> Just move the scope of the grouping and use Nulls in stead of 0's,
> like this:
>
> SELECT stats.which_year AS year,
> SUM(CASE WHEN stats.which_month = 1 THEN stats.quantity ELSE NULL
> END) AS gen,
ELSE NULL is the default
sqlite> create t
thanks to all for the solutions.
I am not sure to have understood the Igor's solution
...SUM(stats.quantity * (stats.which_month = 1)) AS gen
which is the meaning of the operator * in the statement?
regards and still thanks
beppe
On Sat, Dec 21, 2013 at 8:21 PM, James K. Lowden
wrote:
>
On 21 Dec 2013, at 7:45pm, Giuseppe Costanzi wrote:
> I am not sure to have understood the Igor's solution
>
> ...SUM(stats.quantity * (stats.which_month = 1)) AS gen
>
> which is the meaning of the operator * in the statement?
Multiply.
It works because "stats.which_month = 1" is a boo
...but stats.which_month is not a boolean, it represent a month...
On Sat, Dec 21, 2013 at 9:11 PM, Simon Slavin wrote:
>
> On 21 Dec 2013, at 7:45pm, Giuseppe Costanzi
> wrote:
>
> > I am not sure to have understood the Igor's solution
> >
> > ...SUM(stats.quantity * (stats.which_month = 1
On 21 Dec 2013, at 8:24pm, Giuseppe Costanzi wrote:
> On Sat, Dec 21, 2013 at 9:11 PM, Simon Slavin wrote:
>
>> On 21 Dec 2013, at 7:45pm, Giuseppe Costanzi
>> wrote:
>>
>>> I am not sure to have understood the Igor's solution
>>>
>>> ...SUM(stats.quantity * (stats.which_month = 1)) AS gen
Boolean Logic 101 - Feel free to skip if this is not your thread!
-
In addition to other replies - Boolean logic is interesting in that it has no real arithmetic value and can have only true or false
as a value.
I don't know if I have understood well but the statment
SUM(stats.quantity * (stats.which_month = 1))
SUM(stats.quantity * (stats.which_month = 2))
should be interpreted
SUM stats.quantity IF stats.which_month = 1 is TRUE
SUM stats.quantity IF stats.which_month = 2 is TRUE
Am'I still in the dar
On 22-12-2013 08:55, Giuseppe Costanzi wrote:
I don't know if I have understood well but the statment
SUM(stats.quantity * (stats.which_month = 1))
SUM(stats.quantity * (stats.which_month = 2))
should be interpreted
SUM stats.quantity IF stats.which_month = 1 is TRUE
The original '(stats.wh
On Sun, 22 Dec 2013 05:35:55 +0200
RSmith wrote:
> Similarly any attribute can be Boolean if it is found to be an
> attribute of an object. Giuseppe is not Boolean, but he is human and
> likely male, so that: (Giuseppe = Human) is true or 1, and
> (Giuseppe = Female) is false or 0.
>
> For RDBMS
On 2013/12/22 09:55, Giuseppe Costanzi wrote:
I don't know if I have understood well but the statment
SUM(stats.quantity * (stats.which_month = 1))
SUM(stats.quantity * (stats.which_month = 2))
should be interpreted
SUM stats.quantity IF stats.which_month = 1 is TRUE
SUM stats.quantity IF stat
On 2013/12/22 20:53, James K. Lowden wrote:
Similarly any attribute can be Boolean if it is found to be an
attribute of an object. Giuseppe is not Boolean, but he is human and
likely male, so that: (Giuseppe = Human) is true or 1, and
(Giuseppe = Female) is false or 0.
For RDBMS and indeed mo
>So that in all cases, "value" contains the value of stats.quantity when
>the selected month shows up in the iteration loop, and Zero
>when any other month shows up, so Summing the values (or indeed doing any
>other kind of aggregate function on it) will only affect
>stats.quantity values for the s
14 matches
Mail list logo