按日期排序明智的报告? [英] Order by date wise report?
本文介绍了按日期排序明智的报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
- 按日期排序报告问题
选择
liftingbirds,totalweight,avgweight,dcno,
convert ( varchar ,liftingdate, 103 ) as liftingdate
来自
k_LiftingEntryRecords
其中
dcno = @ dcno
订单 按
liftdate desc
这里我没有得到订单明智的日期报告...当我删除条件dcno = @dcno,然后是订单明智的日期报告...
选择
liftingbirds,totalweight, avgweight,dcno,
convert ( varchar ,liftingdate, 103 ) as liftingdate
from
k_LiftingEntryRecords
订单 按
liftingdate desc
其他明智的是它不来......比如
解决方案
嗯。
它是,你知道......它的排序与你指定的一致。
当你选择这个:
选择
liftingbirds,totalweight,avgweight,dcno,
convert ( varchar ,liftingdate, 103 ) as liftingdate您正在创建一个新的临时基于文本的列称为提升日期,它掩盖了基于DateTime的原始版本。
所以当你这样做时:
< span class =code-keyword> order by
liftingdate desc您指定的记录应按新文本column的顺序返回 - 并且排序是文本排序(逐个字符)。
尝试:
选择
liftingbirds,totalweight,avgweight,dcno,
convert ( varchar ,liftingdate, 103 ) as [lifting date ]
来自
k_LiftingEntryRecords
其中
dcno = @ dcno
订单 按
liftingdate 降序
-- Order by date wise report problem
select
liftingbirds, totalweight, avgweight, dcno,
convert(varchar,liftingdate,103) as liftingdate
from
k_LiftingEntryRecords
where
dcno = @dcno
order by
liftingdate desc
Here I am not getting order wise date report ...when I remove where condition dcno = @dcno, then it comes order wise date report...
select
liftingbirds, totalweight, avgweight, dcno,
convert(varchar,liftingdate,103) as liftingdate
from
k_LiftingEntryRecords
order by
liftingdate desc
other wise it's not come.. like
解决方案
Um.
It is, you know...it's sorted exactly as you specified.
When you select this:
select liftingbirds, totalweight, avgweight, dcno, convert(varchar,liftingdate,103) as liftingdateYou are creating a new temporary Text based "column" called "liftingdate", which masks the original DateTime based version.
So when you do this:
order by liftingdate descYou are specifying that the records should be returned in order of the new text "column" - and the sort is a text sort (character by character) as a result.
Try:
select liftingbirds, totalweight, avgweight, dcno, convert(varchar,liftingdate,103) as [lifting date] from k_LiftingEntryRecords where dcno = @dcno order by liftingdate desc
这篇关于按日期排序明智的报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文