假设我有两个表分别包含:
| User | birthday |
| ----------- |:-------------:|
| 'you' | '1980-11-01' |
| 'me' | '1986-12-27' |
和
| Event | date_start | date_end |
| ------------ |:-------------:| ------------- |
| 'e1' | '1980-10-13' | '1980-12-01'
| 'e2' | '1986-01-04' | '1987-01-01'
| 'e3' | '2000-10-13' | '2003-12-01'
并假设对于第二个表中的每个事件,我想选择生日落在日期时间跨度之间的所有用户,即date_start
和date_end
之间的间隔。
显然,JOIN不适合这种需求,有办法吗?作为参考,我对在Redshift数据库上执行此操作特别感兴趣。
答案 0 :(得分:2)
为什么加入还不够?
select *
from event e
join user u on e.date_start < u.birthday and e.date_end > u.birthday
答案 1 :(得分:0)
您可以使用LISTAGG功能
select (select istagg(u.User) within group (order by u.User)
from user u
where
u.birthday >= ev.date_start and u.birthday < ev.date_end )
from event_table ev
答案 2 :(得分:0)
也许这可以是一个解决方案:
Vector2 gravityUp = Vector2.up;
Vector2 gravityDown = Vector2.down;
private void ChangeBoyPosition(GameObject target, MouseEventType type)
{
if (type == MouseEventType.CLICK)
{
int buttonIndex = System.Array.IndexOf(buttons, target);
if (buttonIndex == 0)
{
Physics2D.gravity = gravityDown;
}
else
{
Physics2D.gravity = gravityUp;
}
}
}