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.0Explanation / 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;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.