Does this help
Here is my test table data.
ID;DATE;VALUE
1;"2009-03-13";5
2;"2009-03-13";2
3;"2009-03-11";1
4;"2009-03-11";2
5;"2009-03-11";3
SELECT mydate AS day,
SUM(CASE WHEN id % 2 = 1 THEN value END) AS sum_odd,
SUM(CASE WHEN id % 2 = 0 THEN value END) AS sum_even
FROM xyz
GROUP
pgsql-sql-ow...@postgresql.org wrote:
> "Philippe Lang" writes:
>> I was trying to run this query this morning:
>
>> --
>> SELECT
>
>> r.*,
>
>> (
>> SELECT
>
>> rl.reminder_header,
>> rl.reminder_footer
>
>> FROM reminder_levels AS rl
>> WHERE
"Philippe Lang" writes:
> I was trying to run this query this morning:
> --
> SELECT
> r.*,
> (
> SELECT
> rl.reminder_header,
> rl.reminder_footer
> FROM reminder_levels AS rl
> WHERE rl.lookup =
> (
> SELECT MAX(rem
>
> Original Message
> Subject: Re:[SQL] Subquery problems
> From: Masaru Sugawara <[EMAIL PROTECTED]>
> To: Ranieri Mazili <[EMAIL PROTECTED]>
> Date: 21/6/2007 13:25
> > On Tue, 19 Jun 2007 09:17:22 -0300
> > Ranieri Mazili <[EMAIL PROTECTED]&g
On Tue, 19 Jun 2007 09:17:22 -0300
Ranieri Mazili <[EMAIL PROTECTED]> wrote:
Hi,
This reply is not accurate, but I think there are helpful hints.
--
Masaru Sugawara
select
C.id_production_area,
B.id_machine_type,
A.h_month as month,
max(A.n) as div_mes,
cast((sum(A.qty_employees_t
On 12/11/06, Shoaib Mir <[EMAIL PROTECTED]> wrote:
Oh that explains a lot...
Thank you,
-
Shoaib Mir
EnterpriseDB (www.enterprisedb.com)
On 12/11/06, Michael Glaesemann <[EMAIL PROTECTED]> wrote:
>
>
> On Dec 11, 2006, at 15:48 , Shoaib Mir wrote:
>
> > create table myt1 (a numeri
Oh that explains a lot...
Thank you,
-
Shoaib Mir
EnterpriseDB (www.enterprisedb.com)
On 12/11/06, Michael Glaesemann <[EMAIL PROTECTED]> wrote:
On Dec 11, 2006, at 15:48 , Shoaib Mir wrote:
> create table myt1 (a numeric);
> create table myt2 (b numeric);
>
> select a from myt1
On Dec 11, 2006, at 15:48 , Shoaib Mir wrote:
create table myt1 (a numeric);
create table myt2 (b numeric);
select a from myt1 where a in (select a from myt2);
This should be giving an error that column 'a' does not exist in
myt2 but it runs with any error...
The a in the IN clause is the
I just noticed the same behavior in Oracle and SQL Server as well :)
Regards,
-
Shoaib Mir
EnterpriseDB (www.enterprisedb.com)
On 12/11/06, Shoaib Mir <[EMAIL PROTECTED]> wrote:
I just noticed an abnormal behavior for the subquery:
create table myt1 (a numeric);
create table myt2 (b n
On 12/11/06, Shoaib Mir <[EMAIL PROTECTED]> wrote:
I just noticed an abnormal behavior for the subquery:
create table myt1 (a numeric);
create table myt2 (b numeric);
select a from myt1 where a in (select a from myt2);
This should be giving an error that column 'a' does not exist in myt2 b
I dont think you need the double-left join
SELECT * FROM STORIES ST
LEFT JOIN TAGS TG ON TG.tagkey = ST.storykey
WHERE TG.tag = "science"
"MRKisThatKid" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi, i've posted this in various places but I'm really struggling to
> find
On Thu, 4 Oct 2001 [EMAIL PROTECTED] wrote:
> What mistake have I made?
>
> database1=# UPDATE mytable SET
> NextNumber=NextNumber+1
> database1-# WHERE id='ID1' AND EffectiveDate=
> database1-# (SELECT MAX(s2.EffectiveDate) FROM
> mytable s2
> database1(# WHERE s2.id=id AND
> s2.EffectiveDate<
Carl van Tast <[EMAIL PROTECTED]> wrote in message
news:<[EMAIL PROTECTED]>...
> Hi A.,
>
> On 26 Sep 2001 07:24:41 -0700, [EMAIL PROTECTED] (A. Mannisto)
> wrote:
>
> >Hello,
> >
> >does anybody know why this:
> >SELECT * FROM tab WHERE col1 IN (SELECT col2 FROM TAB2)
> >
> >equals this:
> >SE
Hi A.,
On 26 Sep 2001 07:24:41 -0700, [EMAIL PROTECTED] (A. Mannisto)
wrote:
>Hello,
>
>does anybody know why this:
>SELECT * FROM tab WHERE col1 IN (SELECT col2 FROM TAB2)
>
>equals this:
>SELECT * FROM tab WHERE EXISTS (SELECT col2 FROM TAB2 WHERE col1 =
>col2)
>
>but this:
>SELECT * FROM tab
I did something similar, but pu the subselect into a view, in the WHERE clause.
SELECT * FROM modules m WHERE (m.module_ident = (SELECT
max(modules.module_ident) AS max FROM modules WHERE (m.moduleid =
modules.moduleid) GROUP BY modules.moduleid));
The equivalent for you would be something like:
"kakerjak" <[EMAIL PROTECTED]> writes:
> If the subquery is placed before the JOIN, like it is above, then the error
> i get says 'parse error at or near "select"'
> If i flip the subquery around with the laboratory table then i get 'parse
> error at or near "("'
Are you using 7.1?
What version of postgresql are you using?
On 27 Jun 2001 17:09:14 -0400, kakerjak wrote:
> Hey all..
>
> Here's the table definition.
> CREATE TABLE "laboratory" (
> "id" "int4" NOT NULL,
> "subid" "int2" NOT NULL,
> "name" varchar(30) NOT NULL,
> CONSTRAINT "laboratory_pkey" PRI
17 matches
Mail list logo