我有一张CAR表,我想知道每个MODEL在数据库中有多少PIECES? (模型也包含子模型,但它们一起很好)。 到目前为止:
SELECT MODEL DM, MODEL CM
FROM CAR
WHERE DM = (DISTINCT MODEL)
AND CM = (COUNT MODEL);
答案 0 :(得分:2)
也许我误解了你,但这不会解决你的问题:
def circleMask(mat, r=0):
if mat.shape[0] != mat.shape[1]:
raise TypeError('Matrix has to be square')
if not isinstance(r, int):
raise TypeError('Radius has to be of type int')
s = mat.shape[0]
d = num.abs(num.arange(-s/2 + s%2, s/2 + s%2))
dm = num.sqrt(d[:, num.newaxis]**2 + d[num.newaxis, :]**2)
return num.logical_and(dm >= r-.5, dm < r+.5)
如果要计算列的不同值的数量,因为单个值可能有多个条目,您可以使用它:
SELECT MODEL , COUNT(*)
FROM CAR
GROUP BY MODEL ;