Çë½Ì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
Ïà¹ØÎÊ´ð£º
ÎÒÓжà¸ö±íA B C ½á¹¹ÊÇÒ»ÑùµÄ£¬¶¼ÓÐ2¸ö×Ö¶ÎnameºÍcontent,ÎÒÒªËÑË÷ËùÒÔ±íËùÓÐ×Ö¶ÎÖаüº¬¡°Öйú¡±µÄÄÚÈÝ Õâ¸öSQLÓï¾äÔõôд
ÈçºÎ½«¶à¸ö±íµÄ²éѯ½á¹ûÁ¬³ÉÒ»¸ö±í Õâ¸öSQLÓï¾äÔõôд ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ
ÀýÈç£ ......
ÎÒÊÇÔÚtoadÖÐÊäÈë϶Îsql
declare
TYPE test_rec IS record(
code varchar(10),
name varchar(30)
);
v_book test_rec;
......
µÚÒ»¾ä:
select ht.gfdm,gfdm.gfmc,gfdm.lb ,sum(jh.htdj*jh.htsl)as je
from ht left join gfdm on ht.gfdm=gfdm.gfdm
join jh on ht.htbh=jh.hth
and ht.htbh not like'del%' and ht. ......
id url rank ......