This document provides a question asking to write a T-SQL query to return records from a table where each group has at least one different color for the products within that group. The query should return the GroupId, ProductId, and Color columns. It provides sample data in a table called Colors and asks for the solution to be submitted by 4:30 PM without using temporary tables, table variables, common table expressions, or loops. In case of a tie, the winner will be determined by the better execution plan.
This document provides a question asking to write a T-SQL query to return records from a table where each group has at least one different color for the products within that group. The query should return the GroupId, ProductId, and Color columns. It provides sample data in a table called Colors and asks for the solution to be submitted by 4:30 PM without using temporary tables, table variables, common table expressions, or loops. In case of a tie, the winner will be determined by the better execution plan.
This document provides a question asking to write a T-SQL query to return records from a table where each group has at least one different color for the products within that group. The query should return the GroupId, ProductId, and Color columns. It provides sample data in a table called Colors and asks for the solution to be submitted by 4:30 PM without using temporary tables, table variables, common table expressions, or loops. In case of a tie, the winner will be determined by the better execution plan.
This document provides a question asking to write a T-SQL query to return records from a table where each group has at least one different color for the products within that group. The query should return the GroupId, ProductId, and Color columns. It provides sample data in a table called Colors and asks for the solution to be submitted by 4:30 PM without using temporary tables, table variables, common table expressions, or loops. In case of a tie, the winner will be determined by the better execution plan.
Download as DOCX, PDF, TXT or read online from Scribd
Download as docx, pdf, or txt
You are on page 1of 1
Question
Write a T-SQL which will give us records where we have at least 1 different color for the entire group. Columns to be fetched are GroupId, ProductId & Color. Rule(s)
Reply me with your solution before 4:30 PM.
Temp Tables, Table Variables and CTEs are not allowed. No loops please. Your solution should work on SQL Server 2012. In case of tie, winner will be decided via better execution plan !.
Script
--
CREATE TABLE Colors
( GroupID INT , ProductID INT , Color VARCHAR(30) ) GO INSERT INTO Colors VALUES ( 1, 300 ,'Blue'), ( 1, 391 ,'Blue'), ( 1 , 237 ,'Yellow'), ( 2 , 100 ,'Black'), ( 3 , 500 ,'Green'), ( 3 , 501 ,'Green'), ( 4 , 921 ,'Blue'), ( 4 , 834 ,''), ( 4 , 512 ,'Red') GO --