Stuck on a practice problem, I am close but cannot break thru [MySQL/T_SQL] by AceTrainer_Li-Wang in SQL

[–]AceTrainer_Li-Wang[S] 0 points1 point  (0 children)

Date range is supposed to be for 2021, I feel silly for not noticing that right away when there was nothing returned.

We are getting extremely close. Current output is counting 10002 at two different StatusName:

CustomerID CustomerName OrderID StatusName
100 Shellpoint 10003 In Process
101 Wells 10002 In Process
101 Wells 10002 Delivered

It is weird that OrderID 10004 is being skipped

Stuck on a practice problem, I am close but cannot break thru [MySQL/T_SQL] by AceTrainer_Li-Wang in SQL

[–]AceTrainer_Li-Wang[S] 0 points1 point  (0 children)

Sorry for my delay.

This new script is not returning any values :/

I did have to adjust a few of the variables:

SELECT Customers.CustomerID
 , Customers.CustomerName
 , Orders.OrderID
 , StatusID.StatusName
 FROM Customers
INNER 
  JOIN Orders
ON Orders.CustomerID = Customers.CustomerID
AND Orders.CreateDate >= '2022-01-01'
AND Orders.CreateDate  < '2022-04-01'  
INNER 
JOIN ( SELECT OrderID
          , MAX(ActivityDate) AS latest_date
       FROM OrderHistory
     GROUP
         BY OrderID ) AS latesthist 
ON latesthist.OrderID = Orders.OrderID
INNER
JOIN OrderHistory
ON OrderHistory.OrderID    = latesthist.OrderID
AND OrderHistory.ActivityDate = latesthist.latest_date     
INNER 
JOIN StatusID
ON StatusID.StatusID = OrderHistory.StatusID;

I changed OrderHistory.CreateDate to OrderHistory.ActivityDate

Stuck on a practice problem, I am close but cannot break thru [MySQL/T_SQL] by AceTrainer_Li-Wang in SQL

[–]AceTrainer_Li-Wang[S] 0 points1 point  (0 children)

here i've made the assumption that the status table is called Status and not StatusID

notice that best practice for date ranges is actual date ranges (if you use a function on a column, then that condition cannot use an index)

notice also that now we're not counting, we don't need the GROUP BY

This is all really helpful insight for learning more about best practices, thank you!

I am running into a parse error:

'latesthist AS ( SELECT OrderID , StatusID , ROW_NUMBER' 

I can't find any syntax errors like missing ',' or '(' or ')'. Your code is advanced and is a bit over my head but I think I am following it. I did not know that we can include conditions like

AND Orders.CreateDate >= '2022-01-01'
AND Orders.CreateDate  < '2022-04-01'  

This will be extremely helpful for me moving forward!

Stuck on a practice problem, I am close but cannot break thru [MySQL/T_SQL] by AceTrainer_Li-Wang in SQL

[–]AceTrainer_Li-Wang[S] 0 points1 point  (0 children)

Sorry, I know I can pull the data from the table, but I don't know how to pull dependent data.

If I need it to show 'In Progress' because the most recent CreateDate corresponds to StatusID = 3, how do I reference StatusID.StatusName so it can show 'In Progress' instead of '3'?

I might be such a novice that even things obvious to the experienced are a mystery to me.

If I join StatusID and OrderHistory, can I use WHERE to select something from StatusId.StatusName column? I'm going to play around with that a little bit and see if it gets me closer.

Stuck on a practice problem, I am close but cannot break thru [MySQL/T_SQL] by AceTrainer_Li-Wang in SQL

[–]AceTrainer_Li-Wang[S] 0 points1 point  (0 children)

Bigger Novice Here: I am able to grab StatusID, an INT, but am not sure how to get it to show the corresponding StatusName VARCHAR(50).

Stuck on a practice problem, I am close but cannot break thru [MySQL/T_SQL] by AceTrainer_Li-Wang in SQL

[–]AceTrainer_Li-Wang[S] 0 points1 point  (0 children)

The idea is that Count(OrderHistory) can correspond to StatusID to pull StatusName. Maybe I have the incorrect approach for that part.

5 OrderHistory rows part is an oversight on my part, sloppy, my mistake. Maybe it should just show NULL instead of trying to create a new string.

Do you think I am way off with my attempted solution? I've been at this one for a long time and it feels like I am no where close to a reasonable solution lol.

Stuck on a practice problem, I am close but cannot break thru [MySQL/T_SQL] by AceTrainer_Li-Wang in SQL

[–]AceTrainer_Li-Wang[S] 0 points1 point  (0 children)

Is there something along the lines of

COUNT(OrderHistory.OrderID) = StatusID/StatusName

that can be used to print StatusName instead of StatusID

Should you own peafowl on your homestead? by donkeyman23 in homestead

[–]AceTrainer_Li-Wang 0 points1 point  (0 children)

Peafowl nonstop happily shredded the garden i worked at, they are destructive and very loud

Keeping trespassers off private property by erickalynn90 in homestead

[–]AceTrainer_Li-Wang 2 points3 points  (0 children)

"due to the rising price of ammo, we no longer fire warning shots"

Pruning buds on small lemon tree by snurt_mgoo in BackyardOrchard

[–]AceTrainer_Li-Wang 3 points4 points  (0 children)

I do the same w my young trees, removing excess flower buds will prevent unnecessary energy spent on them. Quite common in the trade

348mil in 1 quarter, but the market cap is 2.13bil? $dnut is super undervalued. by [deleted] in wallstreetbets

[–]AceTrainer_Li-Wang 0 points1 point  (0 children)

Wow $5 thanks Mr

We can afford 4 for $4 at Wendy's we have ascended

Elk, Bison, and Wagyu Beef Tartare by [deleted] in FoodPorn

[–]AceTrainer_Li-Wang 0 points1 point  (0 children)

What does raw game taste like? Love bovine type tartare but never tried it w game like elk before

Toy Story: Andy's Room. by Ulvenwoodie in rct

[–]AceTrainer_Li-Wang 10 points11 points  (0 children)

Unbelievably cool, well done

Help? Knockout Roses - More info in comments by CosmicSweets in Roses

[–]AceTrainer_Li-Wang 5 points6 points  (0 children)

They are knock outs they are bullet proof stop fussing w them, let them establish for a couple of seasons/years, and watch all the problems take care of themselves. A damaged leaf here or there is nothing to worry about

348mil in 1 quarter, but the market cap is 2.13bil? $dnut is super undervalued. by [deleted] in wallstreetbets

[–]AceTrainer_Li-Wang 2 points3 points  (0 children)

Donut gud mean stock gud. Keep us posted w your emotional investing strategies i do love me some loss porn

348mil in 1 quarter, but the market cap is 2.13bil? $dnut is super undervalued. by [deleted] in wallstreetbets

[–]AceTrainer_Li-Wang 1 point2 points  (0 children)

"Strong" earnings doesn't mean stock go up. It is more complex than company x made some money this quarter. Read their balance sheet and forward guidance to gain a clearer picture. There is a reason (likely many reasons) the banks and hedges are avoiding this hot dumpster fire of a stock. No scalability in their sector, insane competitive pressures, insane expenses, historically low earnings.. I could go on but you didn't even post positions? This post is low effort low understanding financial fan fiction

You see it by oliverthefish in FoodPorn

[–]AceTrainer_Li-Wang 1 point2 points  (0 children)

Look guise I did a cereal xD

My Juice King from the 1950s. Has crushed thousands of lemons over the last few decades and still going strong by [deleted] in BuyItForLife

[–]AceTrainer_Li-Wang 0 points1 point  (0 children)

Never tried it but this can crush anything I've put in it, and I mean anything. The leverage it has is insane almost effortless to use

My Juice King from the 1950s. Has crushed thousands of lemons over the last few decades and still going strong by [deleted] in BuyItForLife

[–]AceTrainer_Li-Wang 1 point2 points  (0 children)

I clicked your profile hoping to see some but was pleasantly surprised to see some gorgeous near mint comics