gpt4 book ai didi

mysql - 将 MySQL 查询转换为 SQL Server (MSSQL/SQLSRV)(使用 DISTINCT)

转载 作者:可可西里 更新时间:2023-11-01 07:49:10 24 4
gpt4 key购买 nike

我需要做什么才能将此查询转换为在 SQL Server 中工作?

SELECT 
DISTINCT(map_objetivos.OBJ_RowID) AS test,
map_objetivos.OBJ_Objetivo
FROM
map_admin_caminho_critico_indicadores
INNER JOIN
map_admin_caminho_critico ON CCR_RowID = CCI_CaminhoDR
INNER JOIN
map_indicadores ON IND_RowID = CCI_IndicadorDR
INNER JOIN
map_objetivos ON OBJ_RowID = IND_ObjetivoDR
GROUP BY
map_objetivos.OBJ_RowID

最佳答案

与 MySQL 不同,SQL Server 不允许在选择列表中出现未聚合或分组的字段。此外,您的 DISTINCT 是多余的。试试这个:

SELECT 
map_objetivos.OBJ_RowID AS test,
map_objetivos.OBJ_Objetivo
FROM
map_admin_caminho_critico_indicadores
INNER JOIN
map_admin_caminho_critico ON CCR_RowID = CCI_CaminhoDR
INNER JOIN
map_indicadores ON IND_RowID = CCI_IndicadorDR
INNER JOIN
map_objetivos ON OBJ_RowID = IND_ObjetivoDR
GROUP BY
map_objetivos.OBJ_RowID,
map_objetivos.OBJ_Objetivo

关于mysql - 将 MySQL 查询转换为 SQL Server (MSSQL/SQLSRV)(使用 DISTINCT),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7893969/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com