Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!rice!uupsi!sunic!fuug!funic!nntp.hut.fi!nntp!jsw From: jsw@vipunen.hut.fi (Jaakko S Wallenius) Newsgroups: comp.databases Subject: Re: How do I make this class of report? Message-ID: Date: 26 May 91 21:19:02 GMT References: <1991May8.162003.15605@mck-csc.mckinsey.com> Sender: usenet@nntp.hut.fi (Usenet pseudouser id) Organization: Helsinki University of Technology, Finland Lines: 43 In-Reply-To: hin@mck-csc.mckinsey.com's message of 8 May 91 16:20:03 GMT Nntp-Posting-Host: vipunen.hut.fi In article <1991May8.162003.15605@mck-csc.mckinsey.com> hin@mck-csc.mckinsey.com (John K. Hinsdale) writes: ...... => Take a table with columns NAME, YEAR, SALARY, that looks like: => => NAME YEAR SALARY => ----- ---- ------ => Callahan 88 20000 => Callahan 89 23000 => Callahan 90 27000 => Muldoon 88 15300 => Muldoon 89 20000 => O'Connor 89 30000 => O'Connor 90 34000 => => I'd like to generate a report that shows the salary history => across the page, like so: => => NAME 88 89 90 => ------ ------ ------ ------ => Callahan 20000 23000 27000 => Muldoon 15300 20000 => O'Connor 30000 34000 Following query shold do the thing (with ORACLE) select NAME, decode(YEAR,88,SALARY,null) Y-88, decode(YEAR,89,SALARY,null) Y-89, decode(YEAR,90,SALARY,null) Y-90 from TABLE group by NAME; => John K. Hinsdale => hin@mckinsey.com Jaakko Wallenius Helsinki University of Technology, Finland Jaakko_Wallenius@hut.fi