如果用户多次填写调查问卷,我将尝试仅获取最新调查日期的值。
但是,由于响应表很大,因此我宁愿不在where子句的子查询中这样做
select *
from responses r1
where r1.survey_date = (select MAX(survey_date) from responses r2 where
r1.user_id = r2.user_id);
这是加载数据的示例 https://www.db-fiddle.com/f/chUhe2HjoAa9QRNmp5pfSv/3
答案 0 :(得分:1)
此查询应该可以:
<p>Hello World have a look at <a href="www.laptops.com/apple">Apple Laptops</a>.
For more ino go to <a href="www.apple.com" rel="nofollow noopener">Apple.com</a>
or to <a href="www.appleblog.com" rel="nofollow noopener">Appleblog.com</a>
</p>
您只需要在select *
from responses r1
where r1.survey_date = (select MAX(survey_date) from responses r2 where
r1.user_id = r2.user_id);
上建立索引。