sql语句问题,求解,急!!
select mail,nickname from newregister where nickname in (select name from custom1 where company = '"+lbl_com_cn.Text+"')。
第一行是top 1
如何取第二行,第三行数据呢?
select top 2 from xxx where not in (select top 1 from xxx)这如何嵌套进去呢?
求大神解答
[解决办法]
用row_number()也许好处理一些
[解决办法]
SELECT *, Row_Number() OVER (partition by nickname ORDER BY mail desc) as rownum, mail,nickname from newregister where nickname in (select name from custom1 where company = '"+lbl_com_cn.Text+"')
where rownum=1;2;3;.....
[解决办法]
Select * From (Select Row_Number() Over(Order by Id desc) as row,* from xxx where ....) T Where T.row Between 1 and 2
public static DataTable SelectPage(int pageStart, int pageSize, string SqlString)
{
SqlDataAdapter Adapter = new SqlDataAdapter();
DataTable Table = new DataTable();
using (SqlConnection connetion = new SqlConnection(connectionString))
{
Adapter.SelectCommand = new SqlCommand(SqlString, connetion);
Adapter.Fill(pageStart, pageSize, Table);
return Table;
}
}