🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #804

Re: X Y query

#804
From: harun bolat
Date: Thu, 10 May 2007 06:37
41 lines
2070 bytes
I think you can use subquery to obtain matrix result

But you have to create sql dynamically, and write for every column subquery.

SELECT A.col_1,
  (select col_2 from table2 where col_1 = A.col_1 and .. ) AS "0",
  (select col_2 from table2 where col_1 = A.col_1 and .. ) AS "1",
  (select col_2 from table2 where col_1 = A.col_1 and .. ) AS "2",
  (select col_2 from table2 where col_1 = A.col_1 and .. ) AS "3"
FROM TABLE1 A

"adalberto baldini" <finman@swissonline.ch>, haber iletisinde �unlar� 
yazd�:46418103$1@newsgroups.borland.com...
>I have a procedure that joins two tables and  returns a pairs of columns 
>like :
>
> col_1   col_2
> ------  ------
>  0        0
>  0        1
>  0        2
>  1        1
>  2        0
>  2        1
> .....
>
> I would split col2 into n. columns to represent a matrix result :
>
> a\b    0   1  2  3 ...
> 0      x   x  x
> 1          x
> 2      x   x
> ...
>
> I don't know in advance num^ber of columns I could get.
>
> could anyone suggest if exists any function that could do this or if I 
> need to work with a visual component in Delphi ?
>
> Thans
> Adalberto BAldini 
Technical Details
Message-ID: <4642bdb7@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <46418103$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,3a941881090ec663
X-Google-Attributes: gid114a0e,public
X-Google-Language: ENGLISH,ASCII
From: "harun bolat" <harunbolat@netsim.net>
Newsgroups: borland.public.interbase.sql
References: <46418103$1@newsgroups.borland.com>
Subject: Re: X Y query
Date: Thu, 10 May 2007 09:37:35 +0300
Lines: 43
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 212.174.130.50
Message-ID: <4642bdb7@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1178779063 212.174.130.50 (9 May 2007 23:37:43 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail