Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can I write this sql in qlikview.

WHEN ROI_NBR_SESSIONS_2013.ITEM_ID = 'LR_R6R7'

AND (ROI_NBR_SESSIONS_2013.ACCOUNT_NO LIKE '00074%'

   OR ROI_NBR_SESSIONS_2013.ACCOUNT_NO LIKE '00075%'

    OR ROI_NBR_SESSIONS_2013.ACCOUNT_NO LIKE '0008%')

       THEN SUBSTR(ROI_NBR_SESSIONS_2013.ACCOUNT_NO,1,11)

2 Replies
Josh_Good
Employee
Employee

I'm assuming you are wanted to write this in an expression in the UI.  I also assumed your field names are in the table.field structure because you used the Qualify statement:

If( ROI_NBR_SESSIONS_2013.ITEM_ID = 'LR_R6R7'

AND (ROI_NBR_SESSIONS_2013.ACCOUNT_NO LIKE '00074*'

   OR ROI_NBR_SESSIONS_2013.ACCOUNT_NO LIKE '00075*'

    OR ROI_NBR_SESSIONS_2013.ACCOUNT_NO LIKE '0008*')

       , Left(ROI_NBR_SESSIONS_2013.ACCOUNT_NO,11))


If your fields are loaded into QlikView just a fields names (this is the default) then drop the table names from above.  I.e. replace ROI_NBR_SESSIONS_2013.ACCOUNT_NO with
ACCOUNT_NO

maxgro
MVP
MVP

I think the match function can help you with the or part of the expression

wildmatch( str, expr1 [ , expr2,...exprN ] )

The wildmatch function performs a case insensitive comparison and permits the use of wildcard characters ( * and ?) in the comparison strings.

wildmatch( M, 'ja*','fe?','mar')

returns 1 if M = January

returns 2 if M = fex



If( ROI_NBR_SESSIONS_2013.ITEM_ID = 'LR_R6R7'

AND wildmatch(ROI_NBR_SESSIONS_2013.ACCOUNT_NO, '00074*', '00075*', '0008*')

       , Left(ROI_NBR_SESSIONS_2013.ACCOUNT_NO,11))