这个语句怎么写?(在线)
<p>有如下表:<br/>(批次 名称 进货年份 ......)<br/>num name year ......<br/><strong>000001 A1 1999<br/></strong>000001 A2 1998<br/>000001 A3 2000<br/><strong>000001 A1 2002</strong><br/>000001 B5 2003.<br/>.<br/>.<br/>000022 A1 1995<br/>.<br/>.<br/>.</p><p>问如何删除:同一num中,name相同year较小的记录(如表,第一条记录和第四条记录,符合条件,删除第一条,保留第四条)</p> <p>select num,name,max(year) as year into #tt from Test group by num,name</p><p>delete Test from #tt As tt where Test.num = tt.num and Test.name=tt.name and Test.year<>tt.year</p><p>drop table #tt</p><p></p>[此贴子已经被作者于2006-5-13 10:26:41编辑过]
<p>本贴删除--</p>
[此贴子已经被作者于2006-5-13 9:23:16编辑过]
<p>没测,,试试吧</p>
页:
[1]