日期:2014-05-18  浏览次数:20440 次

100分求一条SQL语句,在线等.

ID,     Name       ,Counts
1         Linux         10
1         linux         30
2         Mac             40
3         Unix           30
3         Unix           40
3         Unix           60


要求取的结果是:ID,     Name       ,Counts
1         linux         30
2         Mac             40
3         Unix           60

------解决方案--------------------
select id,name,max(counts) as counts from table1 group by id,name
------解决方案--------------------
这个100分,是散分贴吧.
select id,name,max(counts) from tb group by id,name
------解决方案--------------------
select ID, Name ,max(Counts) as Counts from 表 group by ID,Name
------解决方案--------------------
select id,name,max(counts) as counts from table1 group by id,name
------解决方案--------------------
看楼主的linuxjava01 (各位旅客请注意:YY次列车就要启动了,请拉好扶手,系) 看了将近1分钟,老在想为什么不写全 "系好安全带 "



------解决方案--------------------
散分帖我来接分...
Select ID,Name,Max(Counts) As Counts From TableName Group By ID,Name
Select * From TableName A Where Not Exists
(Select 1 From TableName Where ID=A.ID And Name=A.Name And Counts> A.Counts)
------解决方案--------------------
try

Select
Count(ID) As Count,
CateName
From
表 A
Where Not Exists(Select ID From 表 Where ID = A.ID And IsNull(CateID, 0) > IsNull(A.CateID, 0))
Group By
CateName
------解决方案--------------------
--这个不对么?
select id,name,max(counts) as counts from table1 group by id,name

------解决方案--------------------
select counts,CateID,A.CateName from
(
select count(EmployeeID) counts ,CateID
from
(
select EmployeeID,max(CateID)
from
(
SELECT HRM004Employee.EmployeeID, HRM004Employee.EmployeeName,
HRM005Category.CateName, HRM005Category.CateID
FROM HRM001Organization INNER JOIN
HRM003DeptEmployee ON
HRM001Organization.OrgID = HRM003DeptEmployee.OrgID INNER JOIN
HRM004Employee ON
HRM003DeptEmployee.EmployeeID = HRM004Employee.EmployeeID AND
HRM004Employee.DeleteFlg = '0 ' AND HRM004Employee.StatusFlag IN ( '0 ', '1 ')
INNER JOIN
HRM002Department ON
HRM001Organization.OrgID = HRM002Department.OrgID AND
HRM003DeptEmployee.DeptID = HRM002Department.DeptID LEFT OUTER JOIN
HRM010StudyExperience ON
HRM010StudyExperience.EmployeeID = HRM004Employee.EmployeeID LEFT OUTER JOIN
HRM005Category ON HRM005Category.CateType = '9 ' AND
HRM005Category.CateID = HRM010StudyExperience.Educational
WHERE (HRM001Organization.ActiveFlg = '1 ')