Re: Returning rows as columns
От | codeWarrior |
---|---|
Тема | Re: Returning rows as columns |
Дата | |
Msg-id | dkqj28$18cu$1@news.hub.org обсуждение исходный текст |
Список | pgsql-sql |
You're looking for a technique generally referred to as a "pivot table" which is really a non-normalized or aggregate view of relational data.... You'll find plenty of examples if you Google "pivot table". "Paul" <paulditerwich@gmail.com> wrote in message news:1131446104.767844.57070@f14g2000cwb.googlegroups.com... > Hi, > > I'm looking for a way to return rows as columns. My problem is the > following. I have three tables: > suppliers,products and productprices. A supplier and a product make a > productprice. A certain product may have an x number of suppliers and > prices. > > Now I have the following query: > select > products.int_artnr,products.str_name,suppliers.str_naam,productprices.flt_price > from products,productprices,suppliers > WHERE products.int_artnr = productprices.int_artnr > AND suppliers.int_crednr=productprices.int_crednr > ORDER BY int_artnr > > This gives me a result but not the one I wanted. I want to have a > dataset that returns the supplierprice and suppliername as a column > behind every product for all suppliers. So you get an x number of > columns. > > Example: > > Number Name Suppl1 Price1 Suppl2 Price2 > > 1 Beer 10 cases Heineken 3.33 Amstel 1.55 > 2 Beer 2 cases Heikenen 1.22 > > > Could someone please give me some pointers if this is achievable and if > yes, how I should do this? > > Thx, > > Paul >
В списке pgsql-sql по дате отправления: