Avatar of Karen Schaefer
Karen SchaeferFlag for United States of America

asked on 

Proper syntax for named subquery - As ABC

Need help with the correct syntax to use a named subquery into another query.

AS VSI  
  SELECT VENDOR_SITE_ID
  FROM tblAll
WHERE creation_date >= ADD_MONTHS(TRUNC(SYSDATE, 'YY'), -24)
    and STATE = 'IL' ;
 
  SELECT *
  FROM VSI
  --INNER JOIN A.VENDOR_ID as
  WHERE (A.VENDOR_NAME like '%DEPARTMENT%'
  or A.VENDOR_NAME like '%ILLINOIS%');

what am I missing to call VSI as the datasource for 2nd query?

Thanks,

Karen
Oracle DatabaseSQL

Avatar of undefined
Last Comment
PortletPaul
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Karen Schaefer
Karen Schaefer
Flag of United States of America image

ASKER

This is my final results:  Thanks for the great assist.

WITH VSI AS
  (
  SELECT VENDOR_SITE_ID, STATE
  FROM tblALL
  WHERE STATE = 'IL'
  )
  SELECT S.VENDOR_NAME, A.VENDOR_SITE_ID, A.STATE
  FROM  tbl123 S
  INNER JOIN VSI A on A.VENDOR_SITE_ID = S.VENDOR_ID;  
  --WHERE (S.VENDOR_NAME like '%DEPARTMENT%'
  --    or S.VENDOR_NAME like '%ILLINOIS%');
Avatar of PortletPaul
PortletPaul
Flag of Australia image

:) Now it makes more sense
Oracle Database
Oracle Database

Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.

81K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo