I have a problem and I will explain the situation to understand more my needs:
- I have all my data in one table, and I have put it into
#All_Data
variable. See attached image to see how it looks like - I want to return data showed in
#Final_Data
table
To do that I have done:
- I have created an
#All_Lots
temp table that contains all lots - And I want to loop on this variable to find how many commands in each lot and put it into the
#Final_Data
temp table with corresponding Lot - I also want to get the min date and put it for the 3rd column
I have tried this query but it’s not working:
Select
#ALL_Data.Lots,
count(Select #All_Data.Commands
From #ALL_Data
Where #ALL_Data.Lots = #ALL_Lots.Lots)
From
#ALL_Data
But this is not working can you help me please thanks a lot