我如何计算行数? [英] How I Make The Row Count ?
本文介绍了我如何计算行数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2张桌子......
第一张桌子: - Job_no
是PK
i have 2 table ...
first table :- Job_no
is PK
Car_id Job_no
------ --------
555 1234
555 1235
666 1255
666 1266
秒表: - job_no
是FK
second table :- job_no
is FK
Job_no item_no
------ -------
1234 1
1234 2
1234 3
1235 1
1235 2
1255 1
1255 2
i想要数 item_no
就像第二个表格,当我插入新的 job_no
时, item_no
计数从第一个
i want count item_no
Like the second table when i insert new job_no
, the item_no
count from the first
推荐答案
你必须使用 COUNT [ ^ ]功能:
You have to use COUNT[^] function:
SELECT Job_no, COUNT(item_no) AS CountOfItemsForJob
FROM SecondTable
GROUP BY Job_no
这篇关于我如何计算行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文