isnull or coalesce isn't working
isnull or coalesce isn't working
От:
Jochen Schmidt <jochen@joyce.giub.uni-bonn.de>
Дата:
HI just started using postgres I want to do a select like the following. I have a table with two columns a and b, where sometimes data are missing. I want to do: SELECT ifnull(a,b) FROM table; ==>ERROR: No such function 'ifnull' with the specified attributes tried the same thing with isnull and coalesce, same error. help?! thanks, jochen -- ............................................................................ . * . . Dipl. Geogr. Jochen Schmidt * | | . . | | | | . . Department of Geography phone +49/0228/739646 | | | | * . . University of Bonn fax +49/0228/739099 | |_| | | |. . Meckenheimer Allee 166 jochen.schmidt@uni-bonn.de \___ |_| |. . D - 53115 Bonn http://slide.giub.uni-bonn.de/~jochen | ___/. . | | . ............................................................................
Re: isnull or coalesce isn't working
От:
Liz Bartlett <khyri@idyllmtn.com>
Дата:
>HI >just started using postgres I want to do a select like the following. >I have a table with two columns a and b, where sometimes data are missing. >I want to do: >SELECT ifnull(a,b) FROM table; > >==>ERROR: No such function 'ifnull' with the specified attributes > >tried the same thing with isnull and coalesce, same error. I would try: SELECT a, b FROM table WHERE (a ISNULL) OR (b ISNULL); On a related note: I have a table with a column of type LOGICAL. Some rows have 't', some have 'f' and some have a NULL value. I wanted to select all the rows that were not TRUE. Using a WHERE clause of feespaid != 't' only returned the rows where the value was 'f'. (As did other variations of a single condition, such as NOT(feespaid = 't').) In the end, I had to add in a second check for the NULL value: SELECT entryid FROM entriesspring2000 WHERE ((feespaid != 't') OR (feespaid ISNULL)) This to me seems counterintuitive. Is there any way I can ask for the rows that do not have a TRUE value without having two conditions? --Liz ---------------------------------------------------------------------- Liz Bartlett*http://www.khyri.com/ 110 E. Wilshire Ave.#G-1 Idyll Mountain Internet*http://www.idyllmtn.com/ Fullerton, CA 92832 Virtual Dog Show Co-ordinator*http://www.dogshow.com/ (714) 526-5656 Tibetan Mastiff Web Site*http://www.tibetanmastiffs.com/