Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL CASEµÄÓ÷¨£¬±ÈÏëÏóÖеÄÇ¿´ó

±íÈçÏÂ
Ò»ÌõÓï¾äÏÔʾËùÓдóÓÚ25ËêºÍϵÄÈË£¬ÒÔÉϵÄÈËÏÔ'´óÁä'
select case when age>25 then '´óÁä' else 'СÁä' end as ÄêÁä¼¶±ð,count(*) as ÈËÊý from infor group by case when age>25 then '´óÁä' else 'СÁä' end
 


Ïà¹ØÎĵµ£º

SQL Server º¯Êý´óÈ«

SQL Server×Ö·û´®´¦Àíº¯Êý´óÈ«
 selectÓï¾äÖÐÖ»ÄÜʹÓÃsqlº¯Êý¶Ô×ֶνøÐвÙ×÷£¨Á´½Ósql server£©£¬
select ×Ö¶Î1 from ±í1 where ×Ö¶Î1.IndexOf("ÔÆ")=1;
ÕâÌõÓï¾ä²»¶ÔµÄÔ­ÒòÊÇindexof£¨£©º¯Êý²»ÊÇsqlº¯Êý£¬¸Ä³Ésql¶ÔÓ¦µÄº¯Êý¾Í¿ÉÒÔÁË¡£
left£¨£©ÊÇsqlº¯Êý¡£
select ×Ö¶Î1 from ±í1 where charindex£¨'Ô ......

ʹÓÃSQLÓï¾äÕÒµ½±íÖÐijÁеĵڼ¸Ãû

SQL> select * from t1;
        ID        AGE
---------- ----------
         1         20
         2&nbs ......

Ò»¶ÎsqlÓï¾äµÄ·ÖÎö

--µ±Ç°Ê¹ÓõÄÊý¾Ý¿âÊÇ ÏµÍ³×Ô´øµÄ master
create database temp1
go --´Ë´¦²»¼ÓgoµÄ»°ÏÂÃæuse temp1 »á±¨´í£ºÕÒ²»µ½´æ´¢¹ý³Ì 'temp1'¡£
use temp1
set xact_abort on
begin tran
create table [order]( --orderÊǹؼü×Ö±ØÐëÓÃ[ ]£»
id int
)
create table fOrder(
id int
)
-- ÏÂÃæµÄ²Ù×÷Ö÷ÒªÊÇΪÁËʵÏÖfO ......

ExcelÖÐÊý¾Ýµ¼Èëµ½SQL ServerÊý¾Ý¿â

using System.Data.SqlClient;
using System.Data.OleDb;
  private void tsmiImportTeacherInfo_Click(object sender, EventArgs e)
        {
            DataSet ds;
        ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ