Skip to content

added solution to lc:1251 #749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated readme_en
  • Loading branch information
Dhoni77 authored Mar 13, 2022
commit 05e8449ed8672144840bda0f9dc76ee28674c463
9 changes: 8 additions & 1 deletion solution/1200-1299/1251.Average Selling Price/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ Average selling price for product 2 = ((200 * 15) + (30 * 30)) / 230 = 16.96
### **SQL**

```sql

SELECT p.product_id,
Round(( Sum(u.units * p.price) + 0.0 ) / ( Sum(units) + 0.0 ), 2)
avg_price
FROM Prices p
INNER JOIN UnitsSold u
ON p.product_id = u.product_id
WHERE u.purchase_date BETWEEN p.start_date AND p.end_date
GROUP BY p.product_id;
```

<!-- tabs:end -->