You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
我用相同的sql在scql和mysql执行,得到的结果误差挺大的,可以解释下原因嘛
scql: SELECT ta.credit_rank, COUNT(*) as cnt, AVG(ta.income) as avg_income, AVG(tb.order_amount) as avg_amount FROM ta INNER JOIN tb ON ta.ID = tb.ID WHERE ta.age >= 20 AND ta.age <= 30 AND tb.is_active=1 GROUP BY ta.credit_rank;
mysql SELECT alice.user_credit.credit_rank, COUNT(*) as cnt, AVG(alice.user_credit.income) as avg_income, AVG(bob.user_stats.order_amount) as avg_amount FROM alice.user_credit INNER JOIN bob.user_stats ON alice.user_credit.ID = bob.user_stats.ID WHERE alice.user_credit.age >= 20 AND alice.user_credit.age <= 30 AND bob.user_stats.is_active=1 GROUP BY alice.user_credit.credit_rank;
我用相同的sql在scql和mysql执行,得到的结果误差挺大的,可以解释下原因嘛
scql:
SELECT ta.credit_rank, COUNT(*) as cnt, AVG(ta.income) as avg_income, AVG(tb.order_amount) as avg_amount FROM ta INNER JOIN tb ON ta.ID = tb.ID WHERE ta.age >= 20 AND ta.age <= 30 AND tb.is_active=1 GROUP BY ta.credit_rank;
[fetch]
2 rows in set: (324.059274ms)
+-------------+-----+-------------------+--------------------+
| credit_rank | cnt | avg_income | avg_amount |
+-------------+-----+-------------------+--------------------+
| 5 | 6 | 18069.77597427368 | 7743.3486404418945 |
| 6 | 4 | 336016.2181968689 | 5499.414562225342 |
mysql
SELECT alice.user_credit.credit_rank, COUNT(*) as cnt, AVG(alice.user_credit.income) as avg_income, AVG(bob.user_stats.order_amount) as avg_amount FROM alice.user_credit INNER JOIN bob.user_stats ON alice.user_credit.ID = bob.user_stats.ID WHERE alice.user_credit.age >= 20 AND alice.user_credit.age <= 30 AND bob.user_stats.is_active=1 GROUP BY alice.user_credit.credit_rank;
+-------------+-----+-------------+-------------------+
| credit_rank | cnt | avg_income | avg_amount |
+-------------+-----+-------------+-------------------+
| 6 | 4 | 336017.5000 | 5499.425048828125 |
| 5 | 6 | 18070.0000 | 7743.466796875 |
+-------------+-----+-------------+-------------------+
2 rows in set (0.00 sec)
The text was updated successfully, but these errors were encountered: