|
Posted by Erland Sommarskog on 04/10/07 21:55
(yin_n_yang74@yahoo.com) writes:
> The final query has all the columns specified in SELECT. Yes, your
> guess is correct - SchedID, ResourceUsed, SuppliesVal, and OrderID
> were what was on my mind as I typed the example.
>
> Their relations are as follows:
>
> Schedule to Resource is 1:N
> Schedule to Supply is 1:N
> Schedule to Order is 1:N
> Order to Food is 1:N
>
> Resource, Supply and Order are not directly related to each other.
> There is no association that you were asking about in b).
So when you want:
>> > Sched2 Resource1 Supply1 Order5
>> > Sched2 Resource2 Supply3 Order6
That's completely arbitrary, and you could just as well be satisfied
with:
> > Sched2 Resource1 Supply3 Order6
> > Sched2 Resource2 Supply1 Order5
Or any other combination? Get data into yet another temp table,
and
SELECT schedule, resource, min(Supply), Min(Order)
FROM #temp
GROUP BY schedule, resource
But arbitrary results sets do not really make sense to me.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Navigation:
[Reply to this message]
|