group by的SQL语句

有一张项目表

CREATE TABLE [ProjectTable] (
[ProjectID] NVARCHAR(16) NOT NULL,
[ProjectName] NVARCHAR(20) NOT NULL ON CONFLICT REPLACE DEFAULT Null,
[DeviceID] INTEGER(16) NOT NULL ON CONFLICT FAIL,
[Description] NVARCHAR(255) NOT NULL ON CONFLICT REPLACE DEFAULT 工程描述);

group by的SQL语句

使用一下的sql语句

select 

distinct 

a.[ProjectID],

a.[ProjectName] 

from 

projecttable as a

得出的结果为

group by的SQL语句

其实想要的数据,只是不同的ProjectID所对应的ProjectName

 

 

修改sql语句为

select 

distinct 

a.[ProjectID],

a.[ProjectName] 

from 

projecttable as a

group by a.[ProjectID]

group by的SQL语句

 

你可能感兴趣的:(group by)