Page 80 - SQL
P. 80

and sum(case when productID = 3 then 1 else 0 end) > 0


        This query selects only groups having at least one record with productID 2 and at least one with
        productID 3.


        Where EXISTS


        Will select records in TableName that have records matching in TableName1.


         SELECT * FROM TableName t WHERE EXISTS (
             SELECT 1 FROM TableName1 t1 where t.Id = t1.Id)


        Read Filter results using WHERE and HAVING online: https://riptutorial.com/sql/topic/636/filter-
        results-using-where-and-having




































































        https://riptutorial.com/                                                                               62
   75   76   77   78   79   80   81   82   83   84   85