You are here: Re: Stored procedure returns duplicates « MsSQL Server « IT news, forums, messages
Re: Stored procedure returns duplicates

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация