Question : Help In Query

Dear Expert, I have written the following query

SELECT   AFFILIATEMEMBER.AFFILIATEMEMBERNO,
         AFFILIATEMEMBER.AFFILIATEMEMBERCLUBNO,
         AFFILIATEMEMBER.CITYOTHER AS OTHERCITY,
         CITY.DESCRIPTION AS CITY,
         CITY.CITY_ID,
         STATE.DESCRIPTION AS STATE,
         STATE.STATE_ID,
         COUNTRY.DESCRIPTION AS COUNTRY,
         COUNTRY.COUNTRY_ID,
         GENDER.DESCRIPTION AS GENDER,
         GENDER.GENDER_ID,
         TITLE.DESCRIPTION AS TITLE,
         TITLE.TITLE_ID,
         CATEGORYGROUP.DESCRIPTION AS CATEGORYGROUP,
         CATEGORYGROUP.CATEGORYGROUP_ID,
         CATEGORYSUBGROUP.DESCRIPTION AS CATEGORYSUBGROUP,
         CATEGORYSUBGROUP.CATEGORYSUBGROUP_ID
  FROM                           AFFILIATEMEMBER
                              INNER JOIN
                                 AFFILIATECLUB
                              ON AFFILIATEMEMBER.AFFILIATEMEMBERCLUBNO =
                                    AFFILIATECLUB.AFFILIATECLUBNO
                           LEFT OUTER JOIN
                              CITY
                           ON AFFILIATEMEMBER.CITY_ID = CITY.CITY_ID
                        LEFT OUTER JOIN
                           GENDER
                        ON AFFILIATEMEMBER.GENDER_ID = GENDER.GENDER_ID
                     LEFT OUTER JOIN
                        TITLE
                     ON AFFILIATEMEMBER.TITLE_ID = TITLE.TITLE_ID
                  LEFT OUTER JOIN
                     STATE
                  ON STATE.STATE_ID = STATE.STATE_ID
               LEFT OUTER JOIN
                  COUNTRY
               ON COUNTRY.COUNTRY_ID = COUNTRY.COUNTRY_ID
            LEFT OUTER JOIN
               CATEGORYGROUP
            ON AFFILIATEMEMBER.CATEGORYGROUP_ID =
                  CATEGORYGROUP.CATEGORYGROUP_ID
         LEFT OUTER JOIN
            CATEGORYSUBGROUP
         ON AFFILIATEMEMBER.CATEGORYSUBGROUP_ID =
               CATEGORYSUBGROUP.CATEGORYSUBGROUP_ID


Problem

AFFILIATEMEMBER.CITYOTHER AS OTHERCITY,
         CITY.DESCRIPTION AS CITY,
         CITY.CITY_ID,
If CITYOTHER IS PRESENT, THEN IT SHOULD NOT DISPLAY  CITY.DESCRIPTION AS CITY,
         CITY.CITY_ID,


IF CITY_ID IS PRESENT THEN IT SHOULD NOT DISPLAY
 CITY.DESCRIPTION AS CITY,
         CITY.CITY_ID,

Answer : Help In Query

Then http:#a33324276 should be right. If you do need the CITY_ID, then

SELECT   AFFILIATEMEMBER.AFFILIATEMEMBERNO,
         AFFILIATEMEMBER.AFFILIATEMEMBERCLUBNO,
         COALESCE(AFFILIATEMEMBER.CITYOTHER, CITY.DESCRIPTION) AS CITY,
         COALESCE(AFFILIATEMEMBER.CITY_ID, CITY.CITY_ID) AS CITY_ID,
         STATE.DESCRIPTION AS STATE,
         STATE.STATE_ID,
         COUNTRY.DESCRIPTION AS COUNTRY,
         COUNTRY.COUNTRY_ID,
Random Solutions  
 
programming4us programming4us