如何检索从未打入一个世纪的球员名字?

时间:2017-11-14 11:01:56

标签: sql sql-server

我的数据是这样的。所以,我希望看到那些在整个职业生涯中从未获得过百分之一的球员名单。 样本数据

enter image description here

5 个答案:

答案 0 :(得分:0)

尝试使用foreach (var systemDto in systems) { var sourceConnectionString = _systemService.GetConnectionStringAsync(systemDto.Ip).Result; var dbConnectionFactory = new DbConnectionFactory(sourceConnectionString, "System.Data.SqlClient"); var dbContext = new DbContext(dbConnectionFactory); var storageRepository = new StorageRepository(dbContext); var usedStorage = storageRepository.GetUsedStorageForCurrentMonth(); var dtUsedStorage = new DataTable(); dtUsedStorage.Load(usedStorage); var dcIp = new DataColumn("IP", typeof(string)) {DefaultValue = systemDto.Ip}; var dcBatchDateTime = new DataColumn("BatchDateTime", typeof(string)) { DefaultValue = batchDateTime }; dtUsedStorage.Columns.Add(dcIp); dtUsedStorage.Columns.Add(dcBatchDateTime); using (var blkCopy = new SqlBulkCopy(destinationConnectionString)) { blkCopy.DestinationTableName = "dbo.tbl"; blkCopy.WriteToServer(dtUsedStorage); } } 的{​​{1}} .. Group by条款来查找从未获得过世纪的球员姓名

Having

答案 1 :(得分:0)

MAX()

答案 2 :(得分:0)

使用GROUP BY ... HAVING

SELECT name
FROM table1
GROUP BY name
HAVING MAX(score) < 100

答案 3 :(得分:0)

试试这个,这里的表名是tblScore

select name,max(score) max_score from tblScore group by name
having max(score)<100

结果是

|name   | max_score|
....................
|kumble | 77
|prasad | 12

答案 4 :(得分:0)

尝试Group ByHaving组合

SELECT
    name
FROM [Table Name]
GROUP BY
    name
HAVING
    MAX(score) < 100