Hello,
This is a continuation of this question. I worked all weekend on this problem without solving it. I'm totally stumped. Essentially, I inherited an interesting table structure. This table structure looks like the following:
GroupTable
* ID
* Name
* Description
GroupItem
* ID
* GroupID
* Name
* CreatedBy
* CreationDate
OpenGroupItem
* ID
* GroupID
* Name
* CreatedBy
* CreationDate
I need to get the three most recent GroupItem elements created by a specific user. The twist comes in with a need associated with the GroupID. The three GroupItem elements I retrieve must have at least one other GroupItem element with the same GroupID. The second twist is that the other items in the group may be in OpenGroupItem.
In other words, I am trying to retrieve the three most recent GroupTables that have at least two items in the group. The items can be in either GroupItem or OpenGroupItem. The catch is that at least one of the items must have been created by a specific user.
I have no clue how to accomplish this in SQL. I am using SQL Server 2008 and I keep coming up short.