Received: from resy5.fzk.de (resy5.fzk.de [141.52.68.8]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f9N8HrP45846 for ; Tue, 23 Oct 2001 04:17:53 -0400 (EDT) (envelope-from ch@rodos.fzk.de) Received: by rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id KAA09649; Tue, 23 Oct 2001 10:19:10 +0200 (METDST) From: Haller Christoph Message-Id: <200110230815.KAA29258@rodos> Subject: Re: Query On Case structure To: dineshp@newgen.co.in (Dinesh Parikh) Date: Tue, 23 Oct 2001 10:15:53 METDST Cc: pgsql-sql@postgresql.org In-Reply-To: <001401c1596c$13af7350$f005a8c0@dinesh>; from "Dinesh Parikh" at Oct 20, 101 4:29 pm X-Mailer: Elm [revision: 212.4] X-Archive-Number: 200110/310 X-Sequence-Number: 5263 > > Hi All, > Can we create a query to find different values based on different criteria = > from a table using case structure. For example > Select Into :DBComment Case When localComment Is Null Then Comment When localComment = '123' Then 'Numeric Comment' Else 'String Comment' End from PDBUser Where UserIndex = 23; > > Using such type of structure can we evaluate multiple values. e.g > Select DBComment , DBName, Case When localComment Is Null Then Comment When localComment = '123' Then 'Numeric Comment' Else 'String Comment' End, Case When localName Is Null Then UserName When localName = 'SuperUser' Then 'Supervisor' Else 'NormalUser' End from PDBUser Where UserIndex = 23; > > > Is this possible. If yes then How is it. > Any help/suggestion may be benificial. > > Regards > Dinesh Parikh > NSTL New Delhi > Looks fine to me. What do you want by asking "If yes then How is it." Run the query and have a look on the result. Regards, Christoph