This LINK may help. Then all you have to do is write the Query or C# code.