计数和存储过程 [英] Counting and Stored procedures
本文介绍了计数和存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在尝试创建一个视图(SQL),在该视图中我可以获取产品计数,并可以从该计数中显示计数大于1的任何产品.
[edit]其他OP的信息已从非解决方案中移出[/edit]
我不确定如何在视图中显示每种产品的数量
I am currently trying to create a view(SQL) in which i can get the count of products and from the count be able to show any products which the count is greater than 1.
[edit]additional OP''s information moved from non-solution[/edit]
I am not sure how to get the count of each product to show in the view
SELECT <big>COUNT(dbo.Receiving.ManufacturerSerialNumber) AS Cnt</big>, dbo.Receiving.ManufacturerSerialNumber, dbo.Receiving.UserId, dbo.Receiving.WorkCompleted,
dbo.FullRepair.EngineersReportId, dbo.FullRepair.UserId AS Technician
FROM dbo.Receiving INNER JOIN
dbo.FullRepair ON dbo.Receiving.ManufacturerSerialNumber = dbo.FullRepair.ProductSerial
推荐答案
尝试这样的事情(请检出HAVING
):
Try something like this (check outHAVING
):
SELECT COUNT(*) AS Cnt,
dbo.Receiving.ManufacturerSerialNumber,
dbo.Receiving.UserId,
dbo.Receiving.WorkCompleted,
dbo.FullRepair.EngineersReportId,
dbo.FullRepair.UserId AS Technician
FROM dbo.Receiving, dbo.FullRepair
WHERE dbo.Receiving.ManufacturerSerialNumber = dbo.FullRepair.ProductSerial
HAVING COUNT(*) > 1;
祝你好运!
Good luck!
我找到了解决方案,谢谢
I have found a solution thanks
这篇关于计数和存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文