小问题 是不是想这样比如说员工姓名 配偶姓名 保险费A B 10B A 10C D 20如果A、B全部在公司则每人只有自己的一份如果两夫妻只有一人在公司上班则有两份对不对? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 --如果如我上面所说,那就分开来算吧--两夫妻全部在公司,我这里select 员工姓名,配偶姓名 ,10 from tableName awhere exists(select 1 from tableName where 员工姓名=a.配偶姓名 and 配偶姓名=b.员工姓名) --只有一个人在公司的select 员工姓名,配偶姓名 ,2*10 from tableName awhere not exists(select 1 from tableName where 员工姓名=a.配偶姓名 and 配偶姓名=b.员工姓名) 如何通过一条SQL语句得到如下效果,在线等!!!!! Windows 2008SP1+SQLSERVER2008 数据库打补丁慢 select * into from 记录顺序怎么不一致? 万分火急! sql注册问题 大神帮我看一下这是什么问题,SQL server 2008配置出错。 mssql中的事务什么意思? SQL连接数对数据库太多对影响效率吗? 怎么清理SQL日志 asp连接2003上的sqlserver的怪事 服务器系统资源占用100%的情况 patindex('%[^-^0-9]%',col)=0??? 关系模式分解的问题,求助
--两夫妻全部在公司,我这里
select 员工姓名,配偶姓名 ,10 from tableName a
where exists(select 1 from tableName where 员工姓名=a.配偶姓名 and 配偶姓名=b.员工姓名)
select 员工姓名,配偶姓名 ,2*10 from tableName a
where not exists(select 1 from tableName where 员工姓名=a.配偶姓名 and 配偶姓名=b.员工姓名)