使用与连接不同

时间:2016-02-01 08:37:37

标签: sql sybase sybase-iq

我创建了加入的东西,给了我大约3 000 000个计数(),但我知道我只需要计数()大约70万,而且这个数量来自表cr.OBJ_Daily_Offers odo 我需要通过表PK得到什么是odo.obj_dailyoffers_id。 我想到的是使用distinct,但我不知道怎么得到allso count(*)以查看结果是否与daily_offers表一样。 我的选择需要像这样。

select distinct odo.OBJ_DAILYOFFERS_ID, *
from cr.obj_daily_offers odo
join cr.obj_val v
    on v.obj_row_id = odo.schedule_id
join cr.OBJ_VAL_OBJ_VAL l on l.OBJ_VAL_OBJ_VAL_ID = v.OBJ_VAL_ID
join cr.OBJ_VAL v1 on v1.OBJ_VAL_ID = l.LINKVALUE_OBJ_VAL_ID
join cr.OBJ_ROW a on a.OBJ_ROW_ID = v1.OBJ_ROW_ID 
join cr.OBJ_VAL v2 on v2.OBJ_ROW_ID = v1.OBJ_ROW_ID and v2.OBJ_FIELD_ID = 750 
join cr.OBJ_VAL v3 on v3.VAL = v2.VAL
join cr.OBJ_ROW a1 on a1.OBJ_ROW_ID = v3.OBJ_ROW_ID and a1.OBJ_ID = 752 
join cr.OBJ_VAL v4 on v4.OBJ_ROW_ID = v3.OBJ_ROW_ID and v4.OBJ_FIELD_ID = 810 

0 个答案:

没有答案