1 Reply Latest reply on Feb 8, 2016 11:00 PM by rp0428

    SQL Subquery usage

    2930134

      Need to check if few ID columns in other tables(W_FREIGHT_TERMS_D) are at the Sales Order Line level in Sales Order Line Table (W_SALES_ORDER_LINE_F) and also I am trying to know there are no duplicate Sales Order Lined IDs. Here is the query that I have created:

         select sales_order_ln_id,count(W_FREIGHT_TERMS_D.ROW_WID)
       from W_SALES_ORDER_LINE_F, W_FREIGHT_TERMS_D 
      where W_FREIGHT_TERMS_D.ROW_WID = W_SALES_ORDER_LINE_F.FREIGHT_TERMS_WID group by sales_order_ln_id ;

      I think I need to use sub-queries, so I have altered the above sql to the find the count but my query returns error saying "the table does not exist":

        select sales_order_ln_id, (select count(ROW_WID) from W_FREIGHT_TERMS_D) as FREIGHT
       from W_SALES_ORDER_LINE_F, FREIGHT 
      where FREIGHT.ROW_WID = W_SALES_ORDER_LINE_F.FREIGHT_TERMS_WID group by sales_order_ln_id ;

      Can someone help me frame the right query to find out W_FREIGHT_TERMS_D.ROW_WID exist at sales_order_ln_id level or in other words there is only one sales_order_ln_id value for FREIGHT.ROW_WID and to know whether they are distinct.

        • 1. Re: SQL Subquery usage

          Can someone help me frame the right query to find out W_FREIGHT_TERMS_D.ROW_WID exist at sales_order_ln_id level or in other words there is only one sales_order_ln_id value for FREIGHT.ROW_WID and to know whether they are distinct.

          Not in this forum they can't.

           

          As the name of the forum says it is ONLY for Sql Developer questions.

           

          Please mark the thread ANSWERED and repost it in the SQL and PL/SQL forum.

          SQL & PL/SQL