Viewing 9 posts - 1 through 10 (of 10 total)
Chris Morris (12/5/2008)
DECLARE @Boston_prdID (numeric)
SET @Boston_prdID = 555
SELECT p.*, c.*, d.DistanceToBoston AS [MinDistanceToBoston]
FROM PRODUCTS p
INNER JOIN OTM o ON o.prdID = p.prdID
INNER JOIN CITIES c ON...
December 5, 2008 at 8:18 am
Chris Morris (12/5/2008)
The definition fior the cities table doesn't include lambertX and lambertY
:blush:
my mistake. Just replace latitude by lambertX and longitude by lambertY in the CITIES definitions.
Sorry!
Chris
December 5, 2008 at 7:52 am
Chris Morris (12/5/2008)
Some sample data would be just grand!
here you go 🙂
--creation of the getDistanceFromID scalar function
CREATE FUNCTION [dbo].[getDistanceFromID]
(
@localID numeric, @localX float, @localY float
)
RETURNS float
AS
BEGIN
DECLARE @i float
DECLARE @lX float,...
December 5, 2008 at 7:30 am
Chris Morris (12/5/2008)
I've used a LEFT JOIN here so you can see the closest city and other cities (rejected rows in the original) in the output.
Chris,
Just read the Best practices,...
December 5, 2008 at 6:51 am
Chris Morris (12/5/2008)
[font="Courier New"]DECLARE @Boston_prdID (numeric)
SET @Boston_prdID = 555
SELECT p.*, c.*
FROM PRODUCTS p
INNER JOIN OTM o ON o.prdID = o.prdID
INNER JOIN CITIES c...
December 5, 2008 at 6:15 am
Chris Morris (12/5/2008)
Lovely stuff, thanks Chris. Last question - can you confirm that you're using SQL Server 2000 and not 2005?
Yes unfortunately.
I've heard of the OVER PARTITION option that's available...
December 5, 2008 at 5:37 am
To give you an idea, I tried this subquery to retrieve an individual product and the distance to the nearest location. It works great as is but as you can...
December 5, 2008 at 5:35 am
Chris Morris (12/5/2008)
Say your reference city is Boston, your requirement would be:
For each and every individual product (which has been sold), list the nearest city to Boston...
December 5, 2008 at 5:30 am
Chris Morris (12/5/2008)
Chris,Do you mean this:
retrieve unique products (prdID) AND the city it's in (postcodeID) AND the shortest distance to a reference city
Cheers
ChrisM
Hi ChrisM,
That's it exactly !!!
Chris
December 5, 2008 at 5:21 am
Viewing 9 posts - 1 through 10 (of 10 total)