以下查询返回40条记录(表示多次记录其姓名的用户数):
select
ownername, ownerfamily, count (*) cnt
into
#p
from
branchdataview
where
trfcode in (1011, 1012, 1014)
group by
ownername, ownerfamily
having
count(*) > 1
select *
from #p
where ownername like N'پروین'
and ownerfamily like N'افشار' --count=2
select ownername, ownerfamily, trfcode, *
from branchdataview with (nolock)
where trfcode in (1011, 1012, 1014)
and ownername like N'پروین'
and ownerfamily like N'افشار' --count=3
这两个查询必须返回相同的结果,但似乎پروین不是پروین!
我和#p
中的其他名字有类似的问题我该如何解决这个问题?
我的最终查询是:
select
branchcode, t.OwnerName, t.OwnerFamily
from
branchdataview b with (nolock)
right join
#p p on p.OwnerName =b.OwnerName and t.OwnerFamily = b.OwnerFamily
where
b.TrfCode in (1011, 1012, 1014)
order by
t.OwnerName, t.OwnerFamily
但由于我提到的问题,它返回72行,而应返回至少80行。
答案 0 :(得分:0)
public static IObservable<T> DelayWhile<T>(this IObservable<T> source, IObservable<bool> delay)
{
return delay
.DistinctUntilChanged()
.StartWith(false)
.Publish(_delay => source
.WithLatestFrom(_delay,
(item, isGateClosed) => isGateClosed
? Observable.Return(item).Delay(_ => _delay)
: Observable.Return(item)
)
.Merge()
);
}
虽然下面为رضاکریمی
返回2行select ownername,ownerfamily,trfcode,*
from branchdataview with (nolock)
where trfcode in (1011,1012,1014) and
ownername like N'رضا' and
ownerfamily like N'کریمی'
似乎第一个查询无法识别出'رضاکریمی'。