注册 登录
编程论坛 VFP论坛

IIF的问题请教

sharpex1 发布于 2024-04-08 17:56, 407 次点击

UPDATE X1 ;
SET AddressCoefficient = IIF(X1.Address IN (SELECT Address FROM X1 WHERE !EMPTY(Address) GROUP BY Address HAVING COUNT(*) > 1), 0.1, 0)

对X1表中的AddressCoefficient 字段进行更新,使用了IIF函数,这里X1.Address IN (SELECT Address FROM X1 WHERE !EMPTY(Address) GROUP BY Address HAVING COUNT(*) > 1) 是不是不能作为判断条件??一直提示缺少逗号(,)
5 回复
#2
sdta2024-04-08 20:39
X1.Address IN (SELECT Address FROM X1 WHERE !EMPTY(Address) GROUP BY Address HAVING COUNT(*) > 1)

VFP中不能这么用吧
#3
easyppt2024-04-08 23:06
程序代码:

Create Curs x1(add1 c(20),Coefficient i Null Default Null)
Insert Into x1(add1) Values('aa')
Insert Into x1(add1) Values('aa')
Insert Into x1(add1) Values('bb')
Insert Into x1(add1) Values('bb')
Insert Into x1(add1) Values('cc')
Insert Into x1(add1) Values('cc')
Insert Into x1(add1) Values('dd')

Update t1 Set t1.Coefficient=Iif(Isnull(t2.add1),0,1) From x1 As t1 ;
    left Join (Select add1,Count(*) As nt From x1 Group By add1 Having Count(*)>1) As t2 On t2.add1=t1.add1

sele x1
browse
#4
laowan0012024-04-09 07:50
VFP中貌似不能这么用
3楼方案可行,逻辑也清晰
把需要用SQL加工的数据集做成查询或临时表,然后按条件更新即可

[此贴子已经被作者于2024-4-9 07:54编辑过]

#5
sharpex12024-04-09 14:25
回复 3楼 easyppt
收到,谢谢
#6
schtg2024-04-10 05:48
回复 3楼 easyppt
高!
1