I've created a ranking system for result that contains score from 1 to 100, when a student gets 100 percent the system ranks the student last in class. I expected the system to rank the student with 100 percent as 1st in class.
I got the result below where the student came out 11th position out of 11 student in the class. My expectation is that this particular student supposed to be the 1st position in class instead of the last position.
Please, i need the help of someone
Thanks
enter image description here
Related
My data set contains company column, job position and ctc column. I want to get top 2 positions in each company based on CTC. Did some group by as below...
I tried -
grp112 = df23.groupby(['company_name','job_position'],as_index=False)['ctc'].max()
df24= pd.merge(df23, grp112, on=['company_hash','job_position'], how='inner',suffixes=(None,'_maxCtc'))
Above 2 lines will show job position based on max ctc, I am not sure how to get 2nd highest paid job position !
I have a table(Below is a sample of what it contains) that shows the userId plus various milestones and admission stages. What I need to do this to look at the highest number in milestone_stage_number for that user and returns the value of milestone, admission stage and milestone_latest_stage. so in the example below the query should only return one line for userid 1 with milestone_stoge_number =4 (which is the max number for that person) and return accepted for the admission stage, milestione_lates_stage = emailed and milestone= emailed. In my actual table I have over 12000 users but I need the query to just return one row per user with the information for the maximum stage Number of that user. I hope this is clear what I need to achieve so if I have use 2 five times only returns the row for the highest numve=ber in Milestone_stage_number and hence after running the query I get one row for user 1 and one row for user 2.
my table is called applicants
Person_id Milestone admission_stage milestone_latest_stage milestone_stage_number
1 Under Review Accepted Accepted 2
1 emailed accepted emailed 4
1 offered accepted accepted 3
1 submitted reviewed offered 1
Could use a qualify and a window function
SELECT * FROM applicants
QUALIFY MAX(milestone_stage_number) OVER (PARTITION BY Person_id) = milestone_stage_number
With a set of data that has for each user an age and a score, I would like to select and plot the lowest 15% of the scores for each age.
Is there a way to simply take out the lowest 15% of scores for each age? This would be preferably in an automated way (don't want to have to repeat process for all 100 ages)
I have tried the conditional formatting but then I would have to manually select what data to keep. I suspect it is a complicated if function that hopefully I wont have to rewrite for each age.
I've created a column that ranks the scores with respect to the other of that age:
RANK(B4,$B$4:$B$426,1)
Then in a new column convert that to a percentage of the total number of entries for that age:
(E4/COUNT($E$4:$E$426))*100
Then an IF statement where it copies the score only if it is in the bottom 15% of scores;
IF(F4<15,B4,"-")
This process is long and messy doesn't seem logical to repeat it 100 times so how to I automate it?
This is my first question on here so bear with me. I have two tables in my Oracle database as following:
modules with fields:
module_code eg. INF211
module_title eg. Information technology
credits eg.20
module_progress with fields:
student_id eg. STU1
module_code eg. INF211
module_year eg. 1
module_percent eg. 65
Each student takes 5 modules a year.
So this is what I want to put this all in one query/view if possible:
Find sum of module percents for a particular student
Find sum of all credits for each module with regards to their module percents.
Divide sum of module percents by sum of credits and multiply by 100 to give me an average grade.
Can this be done?
SELECT student_id,
SUM(credits * module_percent) / SUM(credits) * 100.0
FROM module_progress mp
JOIN modules m
ON m.module_code = mp.module_code
GROUP BY
student_id
I have a RuneScape private server, which stores the player scores in a database.
The highscores load the player's scores and put them into a table.
But now comes the harder part I can't fix:
I want to display the rank of the player. Like: 'Attack level: 44, ranked 12'. So it has to find the rank the user has.
How can I get this to work? I googled for 2 days now, I did not find anything.
I don't know if there's a way to achieve this using the same query.
You could make another query like:
pos = select count(*) from players where attack > 44 + 1
This query would return the number of players ranked above someone. The "plus one" part is to make the rank start at 1 (because the first one won't have anyone ranked above him).
For example, if the table is:
id attack
0 35
1 22
2 121
3 76
pos(3) = 1 (only player 2 is ranked above) + 1 = 2
You can create a view (probably) that shows every players score. Something along these lines might work.
create view player_scores as
select player_id, sum(score)
from scores
group by player_id
That will give you one row per player, with their total score. Having that view, the rank is simple.
select count(*)
from player_scores
where sum > (select sum from player_scores where player_id = 1)
That query will return the number of players having a higher score than player_id = 1.
Of course, if you know your player's score before you run the query, you can pass that score as a parameter. That will run a lot faster as long as the column is indexed.