t表中欄位title分別以一二三開頭分別統計

時間 2021-12-25 15:20:47

1樓:

select count (*) as 記錄數 from t where title like '一%'

二的話就是改where nm like '二%' 其他同理

2樓:左丘藍蘭

留個標記

-------------------------補充,總算解決了這兒問題,方法可能不是很好-------------------

[test1@orcl#23-3月 -10] sql>select * from t5;

aid bid cid

---------- ---------- ----------

1 2 1

2 3

2 2 2

1 2 3

[test1@orcl#23-3月 -10] sql>select c.cid,a.total,b.total,c.total from (

2 select cid,count(cid) as total from t5 where cid is not null group by cid) c

3 left join (select aid,count(aid) as total from t5 group by aid) a on c.cid=a.aid

4 left join (select bid,count(bid) as total from t5 group by bid) b on c.cid=b.bid

5 order by c.cid;

cid total total total

---------- ---------- ---------- ----------

1 2 1

2 2 3 1

3 1 1

3樓:匿名使用者

sql count(*) as 記錄數 from t where left(title,2)="一"

sql count(*) as 記錄數 from t where lef(title,2)="二"

sql count(*) as 記錄數 from t where left(title,2)="三"

4樓:匿名使用者

select left(title,1) ,count(*) from t group by left(title,1)

更新a表中c欄位等於b表的c欄位,條件是當a表中d欄位等於或包含b表d欄位的值。求sql更新語句

update sa set cdefine result.cdefine from sa inner join select sa.code,select top 1 b.cdefine from dis b where b.code in case 查詢當前第一個逗號前得字元 when chari...

SQL中如何在表中新增欄位,在資料表中新增一個欄位的SQL語句怎麼寫

我愛數學 alter table tablename1 add alter column fieldname1 fieldtype nfieldwidth nprecision null not null check lexpression1 error cmessagetext1 default ...

Sql查詢表中除了某個欄位以外的所有欄位的方法

select name from syscolumns where id select max id from sysobjects where xtype u and name 表名 然後去查不等於column1的值不就ok了 方法就這樣了,具體你自己寫去吧 有是有,不過要通過系統表來差,而且語句...