当前位置:操作系统 > Unix/Linux >>

某公司数据库面试题

某公司数据库面试题
 
----------------------------------------------
In database XYZ, there's a table 'run_key' with the following rows:

id batch last_processed
------------------------------
1  5           999
2 6           999
3  7             0
4  5             0
5  6           999
6  7             0
7  5             0
8  6             0
9 7           999
10 7             0

 

 
Write a SQL statement to return the number of rows with last_processed=0 for each batch.
The expected output is:
 
batch count
-------------
5             2
6             1
7             3

 

 
answer:
[sql] 
select batch,count(batch) as count from run_key where last_processed=0 group by batch;  

 


CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,