I have data that looks like this:
Organizations ID name 1 apple2 Orange 3 bananas
From time to time, a process runs and gives each unit a score. The process creates data and combines it into a score table like this:
score id unit_id score date_added 1 1 10 1/2/09 2 2 10 1/2/09 3 1 15 1 / 3/09 4 2 10 1/03/09 5 1 15 1/4/09 6 2 15 1/4/09 7 3 22 1/4/09 I / O With each of the most recently recorded scores, you may be able to select all the institutions, resulting in each data generated in this way: Organizations ID name scores date_added 1 Apple 15 1/4/09 2 Orange 15 1/4/09 3 bananas 15 1/4/09
I can get data for an entity using this query:
Select Entities *, Scores Institutions on INNER join score from .score, scores.date_added institutions. Id = score.i.i.id.s.a institutions.id =? Order by scores.date_added DESC LIMIT 1
But I am in the loss of the way to choose the same for all institutions. I'm probably staring at my face?
Very kind thanks to take the time.
Thanks for the great reactions. I give it a few days to see if any favorite solution is bubbles or not, then I will choose the answer.
UPDATE: I have tried several proposed solutions, the main issue I am facing now is that if a unit is not yet a generating score, then they are not visible in the list.
Looks like SQL, that all institutions should be returned, even if they do not have any posts yet.
UPDATE: Thanks to everyone selected!
I do it like this:
SELECT e * Join S1.score, s1.date_added organizations and INNER scores S1On (E.D. = s1.entity_id) left over pairs score S 2 ON (EID = S 2. NTI and S. 1. ID & lt ; S2.id) where s2.id is tap;
Comments
Post a Comment