查詢該類下的記錄數的SQL語句

時間 2025-03-09 22:40:15

1樓:網友

select count(*)from 你的**名你都沒有把所有的東西貼出來誰知道你要顯示什麼。

假如你有。**aid a1

**bid b1

你要顯示a中的所有以及它所對應的b

那麼可以用left join

select a.*,from a left join b on這樣顯示出來是。

id a1 b1

3 16 null

2樓:

select count(*)from 表名 where 類別列名=該類;

sql 中如何統計某一屬性為某個值的記錄的條數?

3樓:網友

1、建立測試表,create table test_where(id number, value number);

2、插入測試資料。

insert into test_where select round(mod(level,12)),level from dual connect by level < 1000;

commit;

3、查詢表中資料,select t.*,rowid from test_where t;

4、編寫sql,查詢總記錄數、以及id等於9的記錄數;

select count(*)count(case when id = 9 then 1 end) from test_where t;

4樓:網友

那還不簡單,稍微變化一下就好咯,假設你需要統計的那個屬性列名叫『sx』

select sx , count(*)from table group by sx

輸出結果的第一列就是屬性值,第2列就是等於這個屬性有多少條記錄。

sql 查詢語句,關於某個欄位位數判斷。

5樓:網友

1、首先我們準備乙個資料表。

2、然後表中的欄位如下圖所示。

3、接著我們用col_length函式進行欄位的判斷。

4、然後點選執行按鈕。

5、接下來我們就可以看到輸入了下圖的內容,代表是存在的。

6、當然我們還可以寫else的分支語句,在裡面新增不存在時候的邏輯。

6樓:網友

查詢出zjhm長度不是15也不是18位的記錄如下sql server

select *

from tabname

where len(zjhm) <15 and len(zjhm) <18 and

mysqlselect *

from tabname

where length(zjhm) <15 and length(zjhm) <18 and

對informix不瞭解,len,length都試試吧,不行的話,只能等人來解答了。

7樓:為我所愛

select *

from tabname

where zjhm='???'

這樣應該ok的,祝你好運了。

sql語句,完成安部門統計每月記錄數。入下表

select sum case month 時間 when 1 then 1 else 0 as 1月 sum case month 時間 when 2 then 1 else 0 as 2月 sum case month 時間 when 3 then 1 else 0 as 3月 sum case...

sql語句查詢mysql怎麼取前幾天的資料

一棵無所不知的小白菜 1 新建一個test資料庫,在資料庫裡建立一張data資料表。2 在表內插入5條測試資料。3 新建一個php檔案,命名為test.php。4 在test.php檔案內,使用header 方法設定檔案執行的編碼為utf8,避免輸出中文時產生亂碼。5 在test.php檔案內,使用...

SQL語句的寫法,一個SQL語句的寫法

select id,title from 表名 where title 標題 union all select id,title from 表名 where title 標題2 取第一條就是 返回一條就加一個select top 1 from select id,title from 表名 wher...