I am using a statement to using where clause but it is returing error. Below is the statment i am using
select * from (select
a.QST_ID as qID,
a.QST_VER_NO as ver_no,
a.MI_OPTNS_ID as index1,
b.MI_OPTNS_TXT as value
from QST_MI_OPTNS_LINK_TBL a INNER JOIN MI_OPTNS_LIST_TBL b on
a.MI_OPTNS_ID = b.ID)
where (qID, ver_no) in ( (2973,3), (2983,4))
I am receiving syntax error near where statement.
where (qID, ver_no) in ( (2973,3), (2983,4)) ----->> where catx(' ',qID, ver_no) in ( '2973 3', '2983 4')
You can't specify the where clause like that.
You meed to do so,etching like the following. This assumes that you don't need specific combinations.
where qid in (value list) and/or ver_no in (value list).
You can't specify the where clause like that.
You meed to do so,etching like the following. This assumes that you don't need specific combinations.
where qid in (value list) and/or ver_no in (value list).
I believe below is the valid SQL logic for what you're after
select
a.QST_ID as qID,
a.QST_VER_NO as ver_no,
a.MI_OPTNS_ID as index1,
b.MI_OPTNS_TXT as value
from
QST_MI_OPTNS_LINK_TBL a
INNER JOIN
MI_OPTNS_LIST_TBL b
on
a.MI_OPTNS_ID = b.ID
and
(
a.QST_ID=2973 and a.QST_VER_NO=3
or
a.QST_ID=2983 and a.QST_VER_NO=4
)
where (qID, ver_no) in ( (2973,3), (2983,4)) ----->> where catx(' ',qID, ver_no) in ( '2973 3', '2983 4')
Concatenation works of course but it's also certainly the least performant option.
Patrick, Agree. But it is more readable, isn't it ?
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.