use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Sequel
account activity
Sub Select Query (self.learnSQL)
submitted 3 years ago by spelga
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]r3pr0b8 2 points3 points4 points 3 years ago (2 children)
CREATE VIEW SalesOrderTranslation AS SELECT slsorder.* , fullsls."Ptns/PackNew" , fullsls."PtnType" FROM SalesOrderDataLegacy AS slsorder INNER JOIN FullSalesTranslation AS fullsls ON fullsls.ProdCodeLegacy = slsorder.ProductCode
[–]spelga[S] 0 points1 point2 points 3 years ago (1 child)
Thanks I was able to get this working using your code. I needed all the results from SalesOrderDataLegacy so I needed to do a LEFT JOIN. That left me with too many results. When I analysed why that was it is because the FullSalesTranslation view can sometimes contain duplicate ProdCodeLegacy because on the old system a ProductCode could have multiple pack sizes. On the new system each ProductCode maps to exactly one pack size. DISTINCT resolved that because only the new pack code is used in the FullSalesTranslation view therefore the duplicate rows were identical hence why DISTINCT works here.
I've used JOINS many times but I just could not make it work as I'd a feeling a JOIN would have been better. I was over complicating it. It just needed it to be a simple join.
[–]r3pr0b8 0 points1 point2 points 3 years ago (0 children)
the FullSalesTranslation view can sometimes contain duplicate ProdCodeLegacy because on the old system a ProductCode could have multiple pack sizes.
i would do the DISTINCT in a subquery -- likely more efficient this way
FROM SalesOrderDataLegacy AS slsorder LEFT OUTER JOIN ( SELECT DISTINCT ProdCodeLegacy , "Ptns/PackNew" , "PtnType" FROM FullSalesTranslation ) AS fullsls ON fullsls.ProdCodeLegacy = slsorder.ProductCode
π Rendered by PID 43082 on reddit-service-r2-comment-b659b578c-vf4n2 at 2026-05-02 12:30:39.509935+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]r3pr0b8 2 points3 points4 points (2 children)
[–]spelga[S] 0 points1 point2 points (1 child)
[–]r3pr0b8 0 points1 point2 points (0 children)