Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

can we give a select statement in where clause of a select statement

Former Member
0 Kudos

can i give select statement in a select statement where clause

6 REPLIES 6

Former Member
0 Kudos

Hi blalji

you can't do it for open SQL but in case of selecting directly from database (Native SQL) , you can do.

Regards

Wiboon

Former Member
0 Kudos

Hi,

Yes u can give. But its advisable not to do that.

It affects the performance badly.

<b><REMOVED BY MODERATOR></b>

regards,

Pritha.

Message was edited by:

Alvaro Tejada Galindo

Former Member
0 Kudos

No

Regards

Vasu

Former Member
0 Kudos

yes you can do that this is called subquery

just check this

SELECT * FROM SFLIGHT

INTO WA

WHERE SEATSOCC = ( SELECT MAX( SEATSOCC ) FROM SFLIGHT ).

WRITE: / WA-CARRID, WA-CONNID, WA-FLDATE.

ENDSELECT.

But it is not recomended in the performance perspective.

regards

shiba dutta

Former Member
0 Kudos

ya balaji u can do that...

SELECT SINGLE city latitude longitude

INTO (city, lati, longi)

FROM sgeocity

WHERE city IN ( SELECT cityfrom

FROM spfli

WHERE carrid = carr_id AND

connid = conn_id ).

Former Member
0 Kudos

Hi Balaji,

well, you can do first, the select of the "where" clause.

Then, you put your results, in a "ranges" table.

And finally, you do the main select, with this "ranges" in the where clause.

Hope this help you!