select count(tm.ID) from dbo.T_Money as tm
left join dbo.T_Item as ti on tm.ID =ti.ID
where ti.item ='AAA' and tm.[datetime] between '2012-03-01' and '2012-03-21') order by tm.ID DESC 我想查的是两个时间之间的 数据 还有个条件就是 ti.item ='AAA' ,写出来就是查询不对,求高手,。。坐等,,晚上也登。。
最后等到的是查询出来的总条数
left join dbo.T_Item as ti on tm.ID =ti.ID
where ti.item ='AAA' and tm.[datetime] between '2012-03-01' and '2012-03-21') order by tm.ID DESC 我想查的是两个时间之间的 数据 还有个条件就是 ti.item ='AAA' ,写出来就是查询不对,求高手,。。坐等,,晚上也登。。
最后等到的是查询出来的总条数
select count(*) from dbo.T_Money as tm
left join dbo.T_Item as ti
on tm.ID =ti.ID
where ti.item ='AAA' and tm.[datetime] between '2012-03-01' and '2012-03-21'
order by tm.ID DESC
left join dbo.T_Item as ti
on tm.ID =ti.ID
where ti.item ='AAA' and tm.[datetime] between '2012-3-01' and '2012-3-21'
order by tm.ID DESC
select count(*) from dbo.T_Money as tm
left join dbo.T_Item as ti
on tm.ID =ti.ID
where ti.item ='AAA' and(tm.[datetime] between '2012-3-01' and '2012-3-21')
order by tm.ID DESC
运行出来报的这个错,
Column "dbo.T_Money.ID" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
left join dbo.T_Item as ti on tm.ID =ti.ID
where ti.item ='AAA'
and tm.[datetime] between '2012-03-01' and '2012-03-21'
left join T_item as ti on tm.ID=ti.ID
where tm.datetime between '2012-03-01' and '2012-03-21' and ti.item='AAA'
select * from dbo.T_Item as ti where ti.item='AAA') as b
left join
(select * from dbo.T_Money as tm
where tm.[datetime] between '2012-3-01' and '2012-3-21'
) as a on b.ID=a.ItemID
inner join 没用过,,,