<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - Agregowanie stringów]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=118&amp;type=atom"/>
	<updated>2008-12-20T21:09:26Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=118</id>
		<entry>
			<title type="html"><![CDATA[Odp: Agregowanie stringów]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=429#p429"/>
			<content type="html"><![CDATA[W zależności od danych można spróbować wykonać pseudo pivota na tabelce.

Dla przykładu
[code]merlin=> \d t2
      Table "public.t2"
 Column |  Type   | Modifiers 
--------+---------+-----------
 id     | integer | 
 dane1  | text    | 
 dane2  | text    | 
 dane3  | text    | 

merlin=> select  * from t2;
 id | dane1 | dane2 | dane3 
----+-------+-------+-------
  1 |       |       | dane2
  1 | dane  |       | 
  1 |       | dane1 | 
(3 rows)


merlin=> select id, max(dane1),max(dane2), max(dane3) from t2 group by id;
 id | max  |  max  |  max  
----+------+-------+-------
  1 | dane | dane1 | dane2[/code]
Ale to podejście bardziej teoretyczne :)
Trzeba by popatrzeć na dane jakie masz w bazie i się zastanowić na materializowaniem widoków lub klepnięcia jakiś agregatów ;]]]></content>
			<author>
				<name><![CDATA[psocha]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=519</uri>
			</author>
			<updated>2008-12-20T21:09:26Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=429#p429</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Agregowanie stringów]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=424#p424"/>
			<content type="html"><![CDATA[Witam
Posiadam ciekawą sytuację... po stworzeniu widoku pomocniczego (który korzysta z ok. 17 innych pomocniczych widoków) niestety dane, które chciałbym, by były w jednym wierszu, mieszczą się w innym.

ID dane1 dane2 dane3
1 null tekst2 null
1 tekst1 null null
1 null null tekst3

Nigdy nie zajdzie sytuacja, by dla jednego id w tej samej kolumnie wystąpiły dane.
Jaka jest możliwość zagregowania stringów do siebie, by otrzymać wynik:

ID dane1 dane2 dane3
1 tekst1 tekst2 tekst3

Pozdrawiam]]></content>
			<author>
				<name><![CDATA[Loch]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=510</uri>
			</author>
			<updated>2008-12-16T09:11:19Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=424#p424</id>
		</entry>
</feed>
