我想在列中获得最大连续出现的null,如屏幕截图所示。由于此表中还有ID列,因此可以根据它进行排序。 就像在这种情况下一样,输出将是4,因为最多4个空值在一起。
SELECT * INTO #tmp FROM (Select 1 AS ID, 1 as lvl union all
Select 2, 1 union all
Select 3, Null union all
Select 4, Null union all
Select 5, 1 union all
Select 6, 1 union all
Select 7, Null union all
Select 8, Null union all
Select 9, Null union all
Select 10, Null union all
Select 11, 1 union all
Select 12, 1 union all
Select 13, 1 union all
Select 14, 1)x
SELECT * FROM #tmp
DROP TABLE #tmp
我只是不知道从哪里开始,所以任何帮助都会很明显。
答案 0 :(得分:1)
在此link发帖后,我找到了解决问题的方法。给出正确结果为4的查询是:
OleDbCommand cmd1 = new OleDbCommand("select * from patient_det", con);
int count = (int)cmd1.ExecuteScalar();
if (count > 0)
{
Response.Write("<script>alert('Data Existed!!')</script>");
}
else
{
OleDbCommand cmd2 = new OleDbCommand("insert into patient_det values('" + st1 + "' , '" + i1 + "' , '" + i2 + "' , '" + i3 + "' , '" + p1 + "')", con);
cmd2.ExecuteNonQuery();
int temp = cmd2.ExecuteNonQuery();
Response.Write("<script>alert('Registered Successfully!!')</script>");
}