Re: Cant group by non integer - ms access - odbc

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Cant group by non integer - ms access - odbc
Дата
Msg-id 23223.1040227634@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Cant group by non integer - ms access - odbc  (Glenn <glenn@pip.com.au>)
Список 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 по дате отправления:

Предыдущее
От: "Jules Alberts"
Дата:
Сообщение: Re: how to traverse a bytea value in pl/pgsql
Следующее
От: "Patrick Hatcher"
Дата:
Сообщение: Re: Cant group by non integer - ms access - odbc