需求:某条件下获得条码(我已经指定好了'1901000005/1','1901000006/1'条码),条码的最近时间的相应记录?
我的实现步骤:
一,获得条码,和条码的最近时间(以下SQL语句可以实现)Select itemcode ,max(fscandate)as 'thelasttime'
from z_kuka_cjbill
Where itemcode In( '1901000005/1','1901000006/1')
group by itemcode得到以下结果集:
itemcode thelasttime
1901000005/1 2009-01-09 07:03:00.000
1901000006/1 2009-01-09 07:03:00.000
二,以条码、条码的最近时间为条件,查询表z_kuka_cjbill中的其它记录(如何写SQL语句,存储过程我已经写好,在
http://topic.csdn.net/u/20090901/08/a606a395-db35-470d-985a-3502eab8ba48.html中,只要把#Temp取个别名就好了。)
我的实现步骤:
一,获得条码,和条码的最近时间(以下SQL语句可以实现)Select itemcode ,max(fscandate)as 'thelasttime'
from z_kuka_cjbill
Where itemcode In( '1901000005/1','1901000006/1')
group by itemcode得到以下结果集:
itemcode thelasttime
1901000005/1 2009-01-09 07:03:00.000
1901000006/1 2009-01-09 07:03:00.000
二,以条码、条码的最近时间为条件,查询表z_kuka_cjbill中的其它记录(如何写SQL语句,存储过程我已经写好,在
http://topic.csdn.net/u/20090901/08/a606a395-db35-470d-985a-3502eab8ba48.html中,只要把#Temp取个别名就好了。)
解决方案 »
- 三表查询,求SQL
- windows 2003 上安装不了sqlserver 2000
- Sql Server 2005如何建立表的外键?2000的我会,请不要用tsql
- oracle中UPDATE语句的问题
- 在sql里边自带的数据库里边,哪个表是保存登陆信息的??有表保存数据库的操作的信息的吗??
- 請高手們多多指教啦.非常非常感謝!
- 触发器一会能触发一会不能触发 求助。。在线等
- 怎样让时间自动加1?
- 请问在SQL语句中(N')表示什么意思
- copy函数--sql server不支持???
- 问一个客户端连接数的问题
- |zyciis| PowerDesign 12.5 导出的domain在SQL2005中执行报错:'type' 附近有语法错误。
Select itemcode ,max(fscandate)as 'thelasttime'
from z_kuka_cjbill
Where itemcode In( '1901000005/1','1901000006/1')
group by itemcode其实我的需求很简单,就是想把以上得到的结果集。通过以下SQL语句。再重新得到一个新的结果集。Select * From z_kuka_cjbill a Inner Join (
Select itemcode ,max(fscandate)as 'thelasttime'
from z_kuka_cjbill
Where itemcode In( '1901000005/1','1901000006/1')
group by itemcode)b
On a.itemcode=b.itemcode And a.fscandate=b.thelasttime请大家把我需求和以上两句SQL语句结合起来想想,我是否写对了。(百分之九九是正确的)