我的思路是事后循环合并,代码如下:
for (int i = Repeater1.Items.Count - 1; i > 0; i--)
{
HtmlTableCell oCell_previous = Repeater1.Items[i - 1].FindControl("tdDwmc") as HtmlTableCell;
HtmlTableCell oCell = Repeater1.Items[i].FindControl("tdDwmc") as HtmlTableCell; oCell.RowSpan = (oCell.RowSpan == -1) ? 1 : oCell.RowSpan;
oCell_previous.RowSpan = (oCell_previous.RowSpan == -1) ? 1 : oCell_previous.RowSpan; if (oCell.InnerText == oCell_previous.InnerText)
{
oCell.Visible = false;
oCell_previous.RowSpan += oCell.RowSpan;
}
}
for (int i = Repeater1.Items.Count - 1; i > 0; i--)
{
HtmlTableCell oCell_previous = Repeater1.Items[i - 1].FindControl("tdDwmc") as HtmlTableCell;
HtmlTableCell oCell = Repeater1.Items[i].FindControl("tdDwmc") as HtmlTableCell; oCell.RowSpan = (oCell.RowSpan == -1) ? 1 : oCell.RowSpan;
oCell_previous.RowSpan = (oCell_previous.RowSpan == -1) ? 1 : oCell_previous.RowSpan; if (oCell.InnerText == oCell_previous.InnerText)
{
oCell.Visible = false;
oCell_previous.RowSpan += oCell.RowSpan;
}
}
(gj varchar2(10), cs varchar2(10), qy varchar2(10), item varchar2(20), qty number );
select case when aaa.gj_rownum=1 then aaa.gj else null end gj ,
case when aaa.cs_rownum=1 then aaa.cs else null end cs
,case when aaa.qy_rownum=1 then aaa.qy else null end qy
,case when aaa.item_rownum=1 then aaa.item else null end item
,aaa.qty
from (
select aa.*, row_number()over(partition by aa.gj order by rownum ) gj_rownum
,row_number()over(partition by aa.cs order by rownum ) cs_rownum
,row_number()over(partition by aa.qy order by rownum ) qy_rownum
,row_number()over(partition by aa.item order by rownum ) item_rownum
from ( select * from cux_test a order by gj, cs,qy,item ) aa
) aaa;
如果你需要 知道合并的行数 稍加变通即可,还有我这查出的 结果 和你那稍微有差异,你如果仔细看了,就知道是排序不同而已造成的,至于其他可能不一样的地方,基本都大同小异,你稍加变通即可