我在这里有一个查询,任何人都可以帮我计算重复字段的总数吗?
SELECT *
FROM item
INNER JOIN itemgroup on item.itemgroupid = itemgroup.itemgroupid
INNER JOIN status on status.statusid = item.status
INNER JOIN owner on owner.ownerid = item.owner
INNER JOIN
(
SELECT code //, (SELECT count(*) FROM item WHERE ....) as 'total_duplicateds'
FROM item
GROUP BY code
HAVING count(code) > 1
) dup ON item.code = dup.code
项目总数:500 重复代码的项目总数:149
现在我总共返回了 149 个字段,如何将其作为新字段添加到每一行?斜线之后是我学会做它的方式,但这对我来说有点高..
有人可以帮我吗?
更具体地说 ,我想得到的回报是:
itemid | code| itemname | itemgroup | owner | total_duplicateds
1 1000 X 1 1 3
2 1000 X 2 2 3
3 1001 A 1 1 3
4 1000 B 3 1 3
5 1002 U 2 1 3