摘要:1:没有主键的情形: Select identity(int,1,1) as iid,* into #tmp from TableName Select * from #tmp Drop table #tmp2:有主键的情形: Select (Select sum(1) from TableName where KeyField <= a.KeyField) as iid,* from TableName a order by iid
阅读全文
摘要:String sql = "select count(*) as mynum from Trade group by format(StockDate, 'yyyy-MM')";这是按月查询的,其他以此类推。日:SELECT SJoinTime, ID FROM Sale where format(sjointime,'yyyy-MM-dd')=#2009-03-30#另外可用datepart函数:DatePart 函数返回一个 Integer 值,其中包含给定 Date 值的指定组件。Public Overloads Function Da
阅读全文