# Database Discussions > Informix >  How to use calculated column value in where clause

## noexpert

I need to retrieve data filtered by the results of a calculated column - how?

INFORMIX:

SELECT

	TUD_PK_LIST_NO AS PKL,
	TUP_TAG_NO AS TAG,
    (
        CASE 
        	( 
        		CASE (SELECT ttt_prnt_tag_no FROM INTTTT_REC WHERE ttt_itm_ctl_no = tup_itm_ctl_no) WHEN NULL THEN (SELECT MIN(pkc_cmpt_tag_no) FROM INTPKC_REC WHERE pkc_pkg_ctl_no = tup_itm_ctl_no GROUP BY pkc_pkg_ctl_no) ELSE (SELECT ttt_prnt_tag_no FROM INTTTT_REC WHERE ttt_itm_ctl_no = tup_itm_ctl_no) END )
	            WHEN NULL
                THEN (SELECT TRIM(tag_mst_tag_no) FROM INTTAG_REC WHERE tag_itm_ctl_no = tup_itm_ctl_no)
            	ELSE   
		            (
        		    	CASE
            				(
			            		SELECT tag_mst_tag_no 
            					FROM 
            						INTTAG_REC 
			            		WHERE tag_itm_ctl_no = 
            											(
								            				CASE (SELECT ttt_itm_ctl_no FROM INTTTT_REC WHERE ttt_itm_ctl_no = tup_itm_ctl_no) 
            													WHEN NULL 
							            						THEN (SELECT MIN(pkc_cmpt_ctl_no) FROM INTPKC_REC WHERE pkc_pkg_ctl_no = tup_itm_ctl_no GROUP BY pkc_pkg_ctl_no) 
            													ELSE (SELECT ttt_itm_ctl_no FROM INTTTT_REC WHERE ttt_itm_ctl_no = tup_itm_ctl_no)
								            				END 
								            			)

            				)
							WHEN NULL
	        		    	THEN (SELECT TRIM(atg_mst_tag_no) FROM INAATG_REC WHERE atg_itm_ctl_no = 
            																				(
																	            				CASE (SELECT ttt_itm_ctl_no FROM INTTTT_REC WHERE ttt_itm_ctl_no = tup_itm_ctl_no) 
																	            					WHEN NULL 
																            						THEN (SELECT MIN(pkc_cmpt_ctl_no) FROM INTPKC_REC WHERE pkc_pkg_ctl_no = tup_itm_ctl_no GROUP BY pkc_pkg_ctl_no) 
																	            					ELSE (SELECT ttt_itm_ctl_no FROM INTTTT_REC WHERE ttt_itm_ctl_no = tup_itm_ctl_no)
																	            				END 
																	            			)
            					)
	            			ELSE
            				(
			            		SELECT TRIM(tag_mst_tag_no) 
            					FROM 
            						INTTAG_REC 
			            		WHERE tag_itm_ctl_no = 
            											(
								            				CASE (SELECT ttt_itm_ctl_no FROM INTTTT_REC WHERE ttt_itm_ctl_no = tup_itm_ctl_no) 
            													WHEN NULL 
							            						THEN (SELECT MIN(pkc_cmpt_ctl_no) FROM INTPKC_REC WHERE pkc_pkg_ctl_no = tup_itm_ctl_no GROUP BY pkc_pkg_ctl_no) 
							            						ELSE (SELECT ttt_itm_ctl_no FROM INTTTT_REC WHERE ttt_itm_ctl_no = tup_itm_ctl_no)
            												END 
								            			)            
            				)            	
	            		END
            )
        END
    ) AS MASTER,


FROM BLA BLA BLA
WHERE `MASTER` = '123456'




Your help is appreciated.

----------

