Õâ¸ösqlÓï¾äÔõôд
±ÈÈçÒ»¸ö±íÓÐa,b,c,d£¬e 5¸ö×Ö¶Î
·µ»Ø a=1,b=1,d=1µÄ¼Ç¼Êý·Ö±ðÓжàÉÙ¸ö¡£·µ»ØÒ»¸öÁ½ÁеÄtable
µÚÒ»ÁÐΪ×Ö¶ÎÃû£¬µÚ¶þÁжÔÓ¦¼Ç¼Êý¡£ÓÃÒ»¾äsqlÓï¾ä
SQL code:
select a,count(*) from (
select a from tb where a=1
union all
select b from tb where b=1
union all
select d from tb where d=1
)t group by a
SQL code:
select 'a' as ×Ö¶ÎÃû,sum(case when a=1 then 1 else 0 end) as ¼Ç¼Êý from tb
union all
select 'b' as ×Ö¶ÎÃû,sum(case when b=1 then 1 else 0 end) as ¼Ç¼Êý from tb
union all
select 'd' as ×Ö¶ÎÃû,sum(case when d=1 then 1 else 0 end) as ¼Ç¼Êý from tb
select col,count(1) as ¼Ç¼Êý from tb group by col
SQL code:
select a as 'ÁÐÃû','¸öÊý'=(select count(a) from table where a=1)
union all
select b as 'ÁÐÃû','¸öÊý'=(select count(b) from table where b=1)
union all
select das 'ÁÐÃû' ,'¸öÊý'=(select count(d) from table where d=1)
select ×Ö¶Î='a',(select cout(1) from table where a=1)
union all
select 'b',(select cout(1) from table where b=1)
union all
select 'c',(select cout(1) from table where c=1)
SQL code
{{-
Ïà¹ØÎÊ´ð£º
select convert(varchar(50),cast(convert(numeric(18,2),1275674000000/100000000)as real))+'ÒÚ'
select cast(convert(numeric(18,2),1275674000000/100000000)as real)
ΪʲôÉÏÒ»¸öÓÃvarcharת»»ºó¾ÍÖ»±£ÁôÁËÒ ......
ÏÖÔÚÓÐÒ»ORACLEÖеÄSQLÓï¾ä£¬ÐèÒªÒÆÖ²µ½DB2ÖУ¬ÇëÎʸÃSQL¸ÄÈçºÎд
ORACLEÖУº
select floor(months_between(date1,date2)) from A
date1,date2·Ö±ðΪ±íÖеÄÁ½¸ö×Ö¶Î £¬¶¼ÎªÈÕÆÚÐÍ
DB2ÖÐÈçºÎʹÓÃÐ ......
ÔÚOracleÖУ¬ÎÒÏë²éϵͳʱ¼äÒ»ÌìµÄÊý¾Ý£¬Ê¹ÓÃÕâ¸öÓï¾ä
select * from tablename
where create_time>SYSDATE-1
and create_time <SYSDATE
ÎÒÏë²é×òÌì00£º00µ½½ñÌì00£º00µÄsqlÔõôд£¬
» ......
Ö±½ÓÆô¶¯ µãÁ˵ÈÒ»»á¶ù¾Íû·´Ó¦ÁË È¥·þÎñÄÇÀïÆô¶¯»á³öÏÖÈçÏÂÌáʾ
³öÏÖ¡°±¾µØ¼ÆËã»úÉϵÄMSSQLSERVER·þÎñÆô¶¯ºóÓÖÍ£Ö¹ÁË¡£Ò»Ð©·þÎñ×Ô¶¯Í£Ö¹£¬Èç¹ûËüÃÇûÓÐʲô¿É×öµÄ
È»ºó»¹ÓÐʲôʲô²»´æÔÚ
......