FName FPlanPrice
1300*1.2外角钢 51.0000000000
0.75*1000*1700外包板 35.0000000000
0.50*1200*1600外包板 30.0000000000
0.40*1200*1620内包板 25.5000000000
0.40*1200*1620内包板 NULL
1300*1.2外角钢 67.000000000
0.50*1200*1600外包板 NULL
0.75*1000*1700外包板 NULLSQL语句是:select a.FName,a.FPlanPrice from a,b where a.FName=b.FName order by a.FPlanPrice desc
我现在想查询出第一次出现FName对应的记录,多余的记录舍弃,该如何做呢,我想要达到效果如下:
FName FPlanPrice
1300*1.2外角钢 51.0000000000
0.75*1000*1700外包板 35.0000000000
0.50*1200*1600外包板 30.0000000000
0.40*1200*1620内包板 25.5000000000即后面四条记录的FNAME前面已经出现过
请高手指点,谢谢!
1300*1.2外角钢 51.0000000000
0.75*1000*1700外包板 35.0000000000
0.50*1200*1600外包板 30.0000000000
0.40*1200*1620内包板 25.5000000000
0.40*1200*1620内包板 NULL
1300*1.2外角钢 67.000000000
0.50*1200*1600外包板 NULL
0.75*1000*1700外包板 NULLSQL语句是:select a.FName,a.FPlanPrice from a,b where a.FName=b.FName order by a.FPlanPrice desc
我现在想查询出第一次出现FName对应的记录,多余的记录舍弃,该如何做呢,我想要达到效果如下:
FName FPlanPrice
1300*1.2外角钢 51.0000000000
0.75*1000*1700外包板 35.0000000000
0.50*1200*1600外包板 30.0000000000
0.40*1200*1620内包板 25.5000000000即后面四条记录的FNAME前面已经出现过
请高手指点,谢谢!
where not eixsts(select 1 from TB where T.FName=FName and T.FPlanPrice>FPlanPrice)
(
select row_number() over(partition by Fname order by getdate()) id,Fname,FPlanPrice from tb
) V
where v.id=1
*
from
tb T
where
not eixsts(select 1 from TB where t.FName=FName and t.FPlanPrice>FPlanPrice)
from a,b where a.FName=b.FName GROUP BY
a.FName order by a.FPlanPrice desc ???
FName FPlanPrice
1300*1.2外角钢 51.0000000000
0.75*1000*1700外包板 35.0000000000
0.50*1200*1600外包板 30.0000000000
0.40*1200*1620内包板 25.5000000000
0.40*1200*1620内包板 NULL
1300*1.2外角钢 12.000000000
0.50*1200*1600外包板 NULL
0.75*1000*1700外包板 NULL 我的意思是现在想把重复的FNAME的去掉,即就取前4条,该如何在此语句上加工