From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 4 Feb 2003 12:31:51 +0300 From: Grigory Batalov To: community@altlinux.ru Message-ID: <20030204093151.GA29699@lrn.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.4i Subject: [Comm] Re: PostgreSQL string functions Sender: community-admin@altlinux.ru Errors-To: community-admin@altlinux.ru X-BeenThere: community@altlinux.ru X-Mailman-Version: 2.0.9 Precedence: bulk Reply-To: community@altlinux.ru List-Unsubscribe: , List-Id: List-Post: List-Help: List-Subscribe: , List-Archive: Archived-At: List-Archive: List-Post: Tue, 4 Feb 2003 11:15:52 +0200 Dmytro O. Redchuk wrote: >> > >> Собственно, вопрос: >> > >> Есть ли в postgres такая функция strstr, substr или им подобные, >> > >> чтобы сделать сразу select substr(strstr(login,'\'),1) as login ? >> > >> Или можно решить эту задачу другим способом? >Мне кажется, можно. >(Там в доке много строковых функций). >(Или ошибаюсь?..) Есть! Несколько громоздко получилось, но зато работает: select substring(login from position(chr(92) in login) + 1) as login, sum(bytes) as bytes from squid_raw_log where time >= $time1 and time < $time2 group by substring(login from position(chr(92) in login) + 1) order by bytes desc; Что скажете? $time1 и $time2 задаются из php для уменьшения выборки. -- Grigory Batalov