Re: Cant group by non integer - ms access - odbc - Mailing list pgsql-novice

From Tom Lane
Subject Re: Cant group by non integer - ms access - odbc
Date
Msg-id 23223.1040227634@sss.pgh.pa.us
Whole thread Raw
In response to Re: Cant group by non integer - ms access - odbc  (Glenn <glenn@pip.com.au>)
List pgsql-novice
Glenn <glenn@pip.com.au> writes:
> Seems I've actually asked the wrong q...
> My query was something like

> "SELECT f1,f2,count(f3) as countOff3, sum(f4) as countoff4,f5,"-" as f6
> FROM mytable
> GROUP BY f1,f2,f5,"-""

You never need to group by a constant, so this would work fine (and be
compliant with the standard, which your given example is not):

SELECT f1,f2,count(f3) as countOff3, sum(f4) as countoff4,f5,"-" as f6
FROM mytable
GROUP BY f1,f2,f5

> Once I took out everything to do with f6, then it worked - however I
> need f6, as this forms a select to be inserted into another table.

Depending on what's happening upstream, it might also help to explicitly
cast the "-" to some specific datatype, eg

    select ..., "-"::varchar as f6 ...

            regards, tom lane

pgsql-novice by date:

Previous
From: "Jules Alberts"
Date:
Subject: Re: how to traverse a bytea value in pl/pgsql
Next
From: "Patrick Hatcher"
Date:
Subject: Re: Cant group by non integer - ms access - odbc