select *
from
(
select
m. MebName,
c.CardNo,
m.MebID,
px=row_number()over(partition by m.MebID order by newid())
from
m_MemberMain as m (nolock)
inner join
m_Card as c (nolock) on m.MebID = c.MebID
where
m.MebID in ({0})
) as t
where
px <= 1
from
(
select
m. MebName,
c.CardNo,
m.MebID,
px=row_number()over(partition by m.MebID order by newid())
from
m_MemberMain as m (nolock)
inner join
m_Card as c (nolock) on m.MebID = c.MebID
where
m.MebID in ({0})
) as t
where
px <= 1
上面这种方法可以先分组再取其中任意一项。 适合于一对多的关系。
SQL 学习。。
select top 100 * from gs_folio where folioid in (select folioid from ac_trans a left join ac_item b on a.itemid= b.itemid where b.arrange= 'CARD')
and folioid in (select folioid from ac_trans a left join ac_item b on a.itemid= b.itemid where b.itemid= 2009)
gs_folio 一对多 ac_trans ac_trans 一对一 ac_item
这种找出来即有现金支出又有银行卡转帐的情况
楼主没有思考CSharp为什么可以解析JavaScript脚本,
所以有了如上的代码,其实我们可以更简单。。。。。。
引入COM组件Microsoft Script Control 1.0
然后如下的代码就可以通过了。。。。。。
public static String ExprToVal(String Expr)
{
MSScriptControl.ScriptControlClass sc = null;
sc = new MSScriptControl.ScriptControlClass();
sc.Language = "JavaScript";
object obj = sc.Eval(Expr);
return obj.ToString();
}
测试:
Console.WriteLine( ExprToVal( " 1 + 2 * (3 + 4)" ) );
datatable.conpute() 也可以动态计算
select top 100 * from gs_folio where folioid in (select folioid from ac_trans a left join ac_item b on a.itemid= b.itemid where b.arrange= 'CARD')
and folioid in (select folioid from ac_trans a left join ac_item b on a.itemid= b.itemid where b.itemid= 2009)
gs_folio 一对多 ac_trans ac_trans 一对一 ac_item
这种找出来即有现金支出又有银行卡转帐的情况
楼主没有思考CSharp为什么可以解析JavaScript脚本,
所以有了如上的代码,其实我们可以更简单。。。。。。
引入COM组件Microsoft Script Control 1.0
然后如下的代码就可以通过了。。。。。。
public static String ExprToVal(String Expr)
{
MSScriptControl.ScriptControlClass sc = null;
sc = new MSScriptControl.ScriptControlClass();
sc.Language = "JavaScript";
object obj = sc.Eval(Expr);
return obj.ToString();
}
测试:
Console.WriteLine( ExprToVal( " 1 + 2 * (3 + 4)" ) );
datatable.conpute() 也可以动态计算