Sql 每日快照表数据,以跟踪随时间的变化

Sql 每日快照表数据,以跟踪随时间的变化,sql,sql-server-2008,Sql,Sql Server 2008,全部 我希望创建一个每天运行的查询,并收集保留在给定字段中的值 本练习的目的是完成我所说的“空白分析”。针对每个公司实体,我们应记录其在10个关键投资组合领域的现有解决方案。游戏的目的是从实体中删除空白 将为每个记录所有者创建一行,该行将带有运行查询的日期戳。其他列将统计已接收条目的字段数 这将使我能够了解每个客户经理如何了解他们的客户群,并跟踪随时间的变化 查询需要为每天运行的查询创建一个新行,以允许我计算随时间的变化 这是我的目标表 CREATE TABLE [dbo].[ProfileSc

全部

我希望创建一个每天运行的查询,并收集保留在给定字段中的值

本练习的目的是完成我所说的“空白分析”。针对每个公司实体,我们应记录其在10个关键投资组合领域的现有解决方案。游戏的目的是从实体中删除空白

将为每个记录所有者创建一行,该行将带有运行查询的日期戳。其他列将统计已接收条目的字段数

这将使我能够了解每个客户经理如何了解他们的客户群,并跟踪随时间的变化

查询需要为每天运行的查询创建一个新行,以允许我计算随时间的变化

这是我的目标表

CREATE TABLE [dbo].[ProfileScore](
[Date] [date] NULL,
[owneridname] [nvarchar](50) NULL,
[Cyber] [nvarchar](50) NULL,
[Encryption] INT NULL,
[Firewall] INT NULL,
[PCIDSS] INT NULL,
[asvscanner] INT NULL,
[pentest] INT NULL,
[phish] INT NULL,
[Scanner] INT NULL,
[TwoFactor] INT NULL,
[customertype] INT NULL,
源数据如下所示

owneridname cyber   encryption  firewall    pcidss  asvscanner  pentest phish   scanner twofactor   customertype
Dave NULL   NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    Customer
Dave NULL   NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    Customer
CRMSERVICE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    Customer
Joey NULL   NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    Customer
Daniel NULL NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    Customer
CRMSERVICE  NULL    NULL    No Opportunity  NULL    NULL    NULL    NULL    NULL    NULL    Customer
Kenny NULL  NULL    WatchGuard  NULL    NULL    NULL    NULL    NULL    NULL    Customer
Daniel NULL NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    Customer
Matt NULL   NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    Customer
CRM Guest 01    NULL    NULL    NULL    No  -- Not Applicable --    Yes NULL    NULL    NULL    Customer
结果表。。。 我想为每个给定的日期每个所有者一行。 然后,每一列将根据其名称统计每个所有者在记录中的非空条目数。 最后一列只是统计每个所有者拥有的记录数

where customertype = 'Customer

DROP TABLE mytable;
CREATE TABLE mytable(
owneridname  VARCHAR(12) NOT NULL PRIMARY KEY
,cyber        VARCHAR(14) NOT NULL
,encryption   VARCHAR(7) NOT NULL
,firewall     VARCHAR(19) NOT NULL
,pcidss       VARCHAR(4) NOT NULL
,asvscanner   VARCHAR(20) NOT NULL
,pentesting   VARCHAR(10) NOT NULL
,phishin      VARCHAR(19) NOT NULL
,scanner      VARCHAR(10) NOT NULL
,twofactor    VARCHAR(6) NOT NULL
,customertype VARCHAR(8) NOT NULL
);
     INSERT INTO mytable   (owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Dave',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRM Support',NULL,NULL,NULL,'No','-- Not Applicable --',NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Dave',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Daniel',NULL,NULL,'WatchGuard','No','-- Not Applicable --',NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Joey',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Daniel',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,'No Opportunity',NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Kenny',NULL,NULL,'WatchGuard',NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Daniel',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Matt',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE','In Action',NULL,NULL,'No','-- Not Applicable --','Yes',NULL,'AppCheck',NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRM Guest 01',NULL,NULL,NULL,'No','-- Not  Applicable --','Yes',NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Joey',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRM Guest 01',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Daniel',NULL,NULL,'WatchGuard',NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Joey',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,'WatchGuard',NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Luke','Not Interested',NULL,'WatchGuard','No','-- Not Applicable --','No','No - Not Interested','In Process','#NAME?','Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Kenny',NULL,'Other',NULL,NULL,NULL,'Yes',NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Joey',NULL,'None','WatchGuard','No','-- Not Applicable --','No',NULL,'None',NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Matt',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Asa',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,'WatchGuard',NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Daniel',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Daniel',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Ryan',NULL,NULL,'Juniper','No','-- Not Applicable --','Yes',NULL,'None','#NAME?','Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Daniel',NULL,NULL,'Cisco',NULL,NULL,'Yes',NULL,'AppCheck',NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Adam',NULL,NULL,NULL,'No',NULL,'Yes',NULL,'AppCheck',NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Matt',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Gareth','Not Interested','Other',NULL,'Yes',NULL,'Yes',NULL,NULL,'#NAME?','Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Gareth',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Kenny',NULL,NULL,NULL,'No','-- Not Applicable --','Yes',NULL,'None',NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Matt',NULL,NULL,'WatchGuard',NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Adam',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Ryan',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Ryan',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Scott',NULL,NULL,'WatchGuard',NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Luke','Not Interested',NULL,'No Opportunity','No','-- Not Applicable --','No','No - Not Interested','In Process','#NAME?','Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Gareth',NULL,NULL,NULL,'Yes',NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('James',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Scott',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Dave','Not Interested',NULL,'Cisco','Yes','-- Not Applicable --','Yes',NULL,'Nessus',NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Matt',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Matt',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,'Yes',NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Gareth','Not Interested','None','WatchGuard','No','-- Not Applicable --','No','No - Not Interested',NULL,'#NAME?','Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,'SonicWALL',NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Dave',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Adam','In Action',NULL,'Palo Alto','Yes',NULL,'Yes',NULL,'AppCheck','#NAME?','Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Ryan',NULL,NULL,'WatchGuard',NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRM Support',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Daniel',NULL,'BeCrypt','Stonesoft StoneGate','Yes',NULL,'Yes',NULL,'None','VASCO','Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Lisa Copley',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'#NAME?','Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,'WatchGuard','No','-- Not Applicable --','Yes',NULL,'None','RSA','Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,'Check Point',NULL,NULL,'Yes',NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Adam',NULL,'PGP','WatchGuard','No','-- Not Applicable --','No',NULL,'None',NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Ryan',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Joey',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Stephanie',NULL,NULL,NULL,NULL,NULL,'No',NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Matt',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Matt',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRM Support',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Matt',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,'No Opportunity',NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRM Support',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Gareth','Not Interested',NULL,'Sophos','Yes',NULL,'Yes','No - Not Interested',NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Alex Evans',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,'Microsoft ISA',NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Kenny',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Matt',NULL,NULL,'WatchGuard',NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRM Support',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Gareth','Not Interested',NULL,'WatchGuard','No','-- Not Applicable --','In Process',NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Matt',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Daniel',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRM Support',NULL,NULL,NULL,'Yes',NULL,'Yes',NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Ryan',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Ryan',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE','Unkown',NULL,'DrayTek',NULL,NULL,'No',NULL,'None','#NAME?','Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,'Sophos',NULL,NULL,NULL,NULL,NULL,NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRMSERVICE',NULL,NULL,'SonicWALL',NULL,NULL,NULL,NULL,'Other','#NAME?','Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('Emma',NULL,NULL,NULL,'Yes',NULL,'Yes',NULL,'Nessus',NULL,'Customer');
    INSERT INTO mytable(owneridname,cyber,encryption,firewall,pcidss,asvscanner,pentesting,phishin,scanner,twofactor,customertype) VALUES ('CRM Support',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Customer');

任何想法都是非常受欢迎的。

像这样的想法应该行得通:

select getdate(), owneridname, count(cyber), count(encryption),
count(1) totalentries
from sourcedata
group by owneridname

我只把网络和加密作为一个例子,但你也可以完成其他领域的计数

使用一些数据和预期结果的一些例子解释会更有帮助。请看这里如何改进问题,抱歉,这有点混乱。我已经更新了主条目@thegameiswar