易截截图软件、单文件、免安装、纯绿色、仅160KB

请教SQL语句查询问题? - MS-SQL Server / 基础类

我想查询出每天数据的最大的一个值。表的格式如下
表名: hisdata
字段 编号 值 状态 时间  
  Id value state dattime  
  101 32.3 0 2010-4-7 12:34:56
  102 19.2 1 2010-4-7 12:34:46
  103 23.2 0 2010-4-7 14:21:02
  101 32.3 0 2010-4-7 15:13:31
  102 19.2 1 2010-4-7 15:28:24
  103 23.2 0 2010-4-7 15:27:46
  --- ---- -- ------
  --- ----- --- ------
  101 32.3 0 2010-4-10 7:56:24
  102 19.2 1 2010-4-10 7:31:32
  103 23.2 0 2010-4-10 8:19:15

  比如要查询2009年4月7日和4月10日之间 编号为101的每天数据的最大值,如何写查询语句 谢谢




up.

SQL code:
select max(value) as maxValue,convert(varchar(10),[dattime],120) as [date]
from hisdata
where convert(varchar(10),[dattime],120) between '2009-04-07' and '2009-04-10'
and Id=101
group by convert(varchar(10),[dattime],120)


select top 1 datetime from testtable4 where Id='101' and convert(datetime,datetime1) between convert(datetime,'2010-04-07 12:00:00') and conve


相关问答:

ASP链接SQL的简单登陆界面 - .NET技术 / ASP.NET

protected void btnLogin_Click(object sender, EventArgs e)
  {
  SqlConnection conn = new SqlConnection("Server = (local);user id = sa;pwd = 1;database = Login");
&nb ......

求一sql语句 - MS-SQL Server / 疑难问题

现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......

请教SQLSERVER的两个问题 - MS-SQL Server / 疑难问题

1。怎样使xp_cmdshell能完整输出超过255个字符的字符串。
2。select 时,检索速度是与from后的 TABLE顺序有关,还是与where条件的顺序有关(TABLE数据多少 )
在系统属性设定里有个选项,可以修改单字段输出字数限制. ......

求一SQL写法 - MS-SQL Server / 基础类

id                           url                   rank     ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号