Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

So I have a table with cmte_id, total, transaction_amt, and less. I want to retu

ID: 3856225 • Letter: S

Question

So I have a table with cmte_id, total, transaction_amt, and less. I want to return a new table that has two columns and two rows. The first column will be cmte_id, with first row C00577130, and second row C00575795. The second column will be prop, which will be the total sum of less for each cmte_id , divided by the total sum of transaction_amt for each cmte_id. How would I go about doing this?

Out[ 324 cmte id total transaction amt less C00577130 1104 1104 NaN 1 C00575795 8800 50 50.0 C00575795 255 51 51.0 3 C00575795 138 69 69.0 4 C00575795 934 934 NaN 5 C00577 130 16 2 2.0 6 C00575795 42 42 42.0

Explanation / Answer

Have used following table to generate sample input/output quer, kindly refer below things,

named table name as cmte,

Expected Query and Output:

SELECT cmte_id, SUM(less)/SUM(transaaction_amt) as amount
FROM cmte
WHERE cmte_id IN ('c00577130','c00575795')
GROUP BY cmte_id;

id cmte_id total transaaction_amt less 1 c00577130 1104 1104 0 2 c00575795 8800 50 50 3 c00575795 255 51 51 4 c00575795 138 69 69 5 c00577130 934 934 0 6 c00577130 16 2 2
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote