Viewing 15 posts - 46 through 60 (of 221 total)
bugg (8/28/2015)
Stephen Beaven-479566 (6/17/2010)
August 28, 2015 at 8:28 am
Stephen Beaven-479566 (6/17/2010)
August 28, 2015 at 8:06 am
Okay this is the best solution I could come up with:
DECLARE @fruit_shop TABLE (shop NVARCHAR(10))
INSERT INTO @fruit_shop VALUES ('shop1'), ('shop2')
DECLARE @tmp TABLE (fruit VARCHAR(50), shop VARCHAR(10), preference INT, InStock...
August 3, 2015 at 10:17 am
Hi All,
I've added in a stock check which will override preference if all stock can be found in one location
CASE WHEN s.InStock >= p.OrderQuantity THEN 1 ELSE 0 END DESC
Which...
August 3, 2015 at 6:39 am
ChrisM@Work (6/25/2015)
SELECT
rn = ROW_NUMBER() OVER(PARTITION BY s.fruit ORDER BY s.Preference),
max_rn = COUNT(*) OVER(PARTITION BY s.fruit),
s.*,
p.OrderQuantity
INTO #StreamedData
FROM @tmp s
INNER JOIN @purchase p...
June 25, 2015 at 4:10 am
Try creating MAX(rn) in the source table #StreamedData: COUNT(*) OVER(PARTITION BY ...) - it's "cleaner" and probably much cheaper 😎
Something like this:
SELECT *,max(rn) over(partition by fruit) AS max_rn INTO #StreamedData
FROM
(
SELECT...
June 25, 2015 at 3:54 am
ChrisM@Work (6/24/2015)
I wonder how a rCTE version would fare, in terms of performance?
Very cool 🙂
I've amended the code to pull in unassigned order quantities similar to spaghetti's output 🙂
DECLARE @tmp...
June 25, 2015 at 3:00 am
spaghettidba (6/24/2015)
DECLARE @tmp TABLE(fruit VARCHAR(50),shop VARCHAR(10),preference INT, qty INT)
INSERT INTO @tmp(fruit,shop,preference,qty) VALUES ('orange','shop 1',1 ,4)
INSERT INTO @tmp(fruit,shop,preference,qty) VALUES ('orange','shop 2',2 ,3)
INSERT INTO @tmp(fruit,shop,preference,qty) VALUES ('orange','shop 3',3 ,5)
INSERT INTO @tmp(fruit,shop,preference,qty)...
June 24, 2015 at 4:26 am
Thanks , I think what I need to try do is assign the cant find fruit to a new "shop" which will be pending stock.
So keep everything how it is...
June 24, 2015 at 2:47 am
There is always a final hurdle! :crying:
I've hit a issue where if there isn't enough stock at shop i get less then the actual desired quantity. I need to...
June 24, 2015 at 2:12 am
spaghettidba (6/19/2015)
Ah, great. Glad I could help.Might sound like a weird question, but: is this really a database for selling fruit? 🙂
🙂 not fruit but selling other products, I...
June 19, 2015 at 6:09 am
spaghettidba (6/19/2015)
I assume you didn't see my latest attempt. It should solve your speed issues.
Yep spotted it , just testing it now .. You are a legend!!! thank you for...
June 19, 2015 at 5:01 am
spaghettidba (6/19/2015)
Sorry, I repeated my tests and yes, it's dog slow 🙂
Yep it slows right down when there are 1000's at each shop. :laugh:
Do you think if I split the...
June 19, 2015 at 4:40 am
spaghettidba (6/19/2015)
This should do:
DECLARE @tmp TABLE(fruit VARCHAR(50),shop VARCHAR(10),preference INT, qty INT)
INSERT INTO @tmp(fruit,shop,preference,qty) VALUES ('orange','shop 1',1 ,1)
INSERT INTO...
June 19, 2015 at 4:03 am
Thanks , I'm really struggling to get my head around this.
Is there no way I can keep a running decreasing balance of the the fruit wanted with the...
June 19, 2015 at 2:08 am
Viewing 15 posts - 46 through 60 (of 221 total)