如何检查表中列的数字分布?

时间:2017-04-23 03:55:18

标签: sql-server

我有这张桌子:

CREATE TABLE [dbo].[Phrase] (
    [PhraseId]              UNIQUEIDENTIFIER DEFAULT (newid()) NOT NULL,
    [English]               NVARCHAR (250)   NOT NULL,
    [EnglishAscii]          AS               (ascii([English])) PERSISTED,
    [EnglishHash]           AS               (CONVERT([bigint],hashbytes('md5',[English])%(5)+(5))) PERSISTED,
    PRIMARY KEY CLUSTERED ([PhraseId] ASC)
);

我想要检查EnglishHash列的分布。

有没有办法可以做一个选择,它会告诉我为EnglishHash的每个值分配了多少行?

1 个答案:

答案 0 :(得分:2)

SELECT EnglishHash, COUNT(*) as [Count] FROM Phrase GROUP BY EnglishHash