<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Forum PostgreSQL - Problem z select case]]></title>
		<link>https://forum.postgresql.org.pl/viewtopic.php?id=392</link>
		<description><![CDATA[Najświeższe odpowiedzi w Problem z select case.]]></description>
		<lastBuildDate>Thu, 04 Feb 2010 12:30:23 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Odp: Problem z select case]]></title>
			<link>https://forum.postgresql.org.pl/viewtopic.php?pid=1796#p1796</link>
			<description><![CDATA[Problem rozwiązany, może komuś się przyda.

select slowo,opis,dodal
from  f.slownik_slowo  where slowo like 
(
	select 
		 case 
				when zmienna='-1' then '%'
				when  (SUM(CHAR_LENGTH(zmienna)))>1 then ('%'||upper(zmienna)||'%')
				else null
				end
				) 
				group by slowo,opis, dodal
Pozdrawiam.]]></description>
			<author><![CDATA[dummy@example.com (gintor)]]></author>
			<pubDate>Thu, 04 Feb 2010 12:30:23 +0000</pubDate>
			<guid>https://forum.postgresql.org.pl/viewtopic.php?pid=1796#p1796</guid>
		</item>
		<item>
			<title><![CDATA[Odp: Problem z select case]]></title>
			<link>https://forum.postgresql.org.pl/viewtopic.php?pid=1794#p1794</link>
			<description><![CDATA[Cześć,
przykładowo przy zmiennej 'ło'
wynika ma być taki:

słońce - opis 1 
słońce - opis 2
słoń - opis 
słony - opis 

czyli mamy dwa razy te same słowo, ale różne opisy.]]></description>
			<author><![CDATA[dummy@example.com (gintor)]]></author>
			<pubDate>Thu, 04 Feb 2010 06:56:19 +0000</pubDate>
			<guid>https://forum.postgresql.org.pl/viewtopic.php?pid=1794#p1794</guid>
		</item>
		<item>
			<title><![CDATA[Odp: Problem z select case]]></title>
			<link>https://forum.postgresql.org.pl/viewtopic.php?pid=1791#p1791</link>
			<description><![CDATA[Ale co ma się pojawić w wyniku jak słowo ma dwa opisy?]]></description>
			<author><![CDATA[dummy@example.com (rski)]]></author>
			<pubDate>Wed, 03 Feb 2010 15:08:32 +0000</pubDate>
			<guid>https://forum.postgresql.org.pl/viewtopic.php?pid=1791#p1791</guid>
		</item>
		<item>
			<title><![CDATA[Problem z select case]]></title>
			<link>https://forum.postgresql.org.pl/viewtopic.php?pid=1790#p1790</link>
			<description><![CDATA[Cześć, 

mam następujący problem. Mam dwie tabele 
slownik_slowo ( id, slowo) oraz
slownik_opis (id,opis)

slownik_slowo.id=slownik_opis.id

Działa mi 1 warunek i 3, problem mam z drugim, 


select 
case
	when	'z1'='-1' then slowo
	when (SUM(CHAR_LENGTH('z1')))>1  then ( select slowo from f.slownik_opis a join f.slownik_slowo b on a.id=b.id  where b.slowo like '%z1%')
	else null 
	---(select slowo from f.slownik_opis a join f.slownik_slowo b on a.id=b.id  where b.slowo like '-1')
	end, 
case 
	when	'z1'='-1' then opis
	when  (SUM(CHAR_LENGTH('z1')))>1 then ( select opis from f.slownik_opis a join f.slownik_slowo b on a.id=b.id  where b.slowo like '%z1%')
	else  null
	--( select opis from f.slownik_opis a join f.slownik_slowo b on a.id=b.id  where b.slowo like '-1')
	end, 
case 
	when	'z1'='-1' then dodal
	when (SUM(CHAR_LENGTH('z1')))>1 then ( select dodal from f.slownik_opis a join f.slownik_slowo b on a.id=b.id  where b.slowo like '%z1%')
	 else null
	 -- (select dodal from f.slownik_opis a join f.slownik_slowo b on a.id=b.id  where b.slowo like '-1')
	end 

from f.slownik_opis a join f.slownik_slowo b on a.id=b.id where slowo like (upper('%-1%'))
group by b.slowo,a.opis, dodal


ERROR:  more than one row returned by a subquery used as an expression

Problem jest jak jedno slowo(czyli zmienna z1) ma dwa opisy.
Jak zbudować funkcję żeby dało się wykonać ten warunek ? Niestety odpada CREATE FUNCTION.

Jakieś podpowiedzi ?]]></description>
			<author><![CDATA[dummy@example.com (gintor)]]></author>
			<pubDate>Wed, 03 Feb 2010 13:02:23 +0000</pubDate>
			<guid>https://forum.postgresql.org.pl/viewtopic.php?pid=1790#p1790</guid>
		</item>
	</channel>
</rss>
