Number of pairs in SQL
Suppose you're given the following table showing sock inventory. Each row represents an individual sock (with the same style/size), and the 'color' column denotes the sock's color. Given this information, write a SQL query to return the number of pairs (two socks with matching colors) that can be made from the inventory shown. Your result should be returned as a single integer number.
You can view/query the data in an interactive SQL fiddle here.
Subscribe to premium account to see the solution.Get premium now