SELECT person.fullname FROM person WHERE - NOTEXISTS( - SELECT - * - FROM - location - WHERE NOTEXISTS(SELECT*FROMitineraryWHEREitinerary.p_id=person.idANDitinerary.loc_id=location.id)) ORDERBY person.fullname;
时间: 2024-03-06 08:49:33 浏览: 17
这是一条可以实现查询人员表去过所有地点的人员姓名,查询结果按人员姓名顺序排序的 SQL 查询语句。以下是格式化后的代码:
```
SELECT person.fullname
FROM person
WHERE NOT EXISTS (
SELECT *
FROM location
WHERE NOT EXISTS (
SELECT *
FROM itinerary
WHERE itinerary.p_id = person.id AND itinerary.loc_id = location.id
)
)
ORDER BY person.fullname;
```
该查询语句使用了两个嵌套的 `NOT EXISTS` 子查询,第一个子查询用于找到去过所有地点的人员,第二个子查询用于在去过所有地点的人员中筛选出去过每个地点的人员。同时使用了 `JOIN` 操作,将 `person`、`location` 和 `itinerary` 表连接起来。最后使用 `ORDER BY` 子句按照人员姓名排序。
相关问题
SELECT p.id AS id, p.fullName AS fullName, p.gender AS gender, p.organizationID AS organizationID, o.ORGNAME AS organizationName, p.mobile AS mobile, WM_CONCAT( j.sworkPlaceName ) AS sworkplaceName FROM base_personfile_person p LEFT JOIN sys_org o ON o.ORGID = p.organizationID LEFT JOIN base_personfile_person_sjob pj ON pj.personId = p.id LEFT JOIN base_personfile_sjob j ON j.ID = pj.sjobId WHERE 1=1 GROUP BY p.id 报不是GROUP BY 表达式
这个错误通常是因为 SELECT 语句中的列与 GROUP BY 子句不匹配。在这种情况下,查询引擎无法确定每个组中应该显示哪些值。
在你的查询中,你使用了 WM_CONCAT 函数来聚合 sworkPlaceName 列,但是你没有在 GROUP BY 子句中包括该列。为了解决这个问题,你需要将 sworkPlaceName 列添加到 GROUP BY 子句中,像这样:
```
SELECT p.id AS id, p.fullName AS fullName, p.gender AS gender, p.organizationID AS organizationID, o.ORGNAME AS organizationName, p.mobile AS mobile, WM_CONCAT(j.sworkPlaceName) AS sworkplaceName
FROM base_personfile_person p
LEFT JOIN sys_org o ON o.ORGID = p.organizationID
LEFT JOIN base_personfile_person_sjob pj ON pj.personId = p.id
LEFT JOIN base_personfile_sjob j ON j.ID = pj.sjobId
GROUP BY p.id, p.fullName, p.gender, p.organizationID, o.ORGNAME, p.mobile
```
这应该会解决你遇到的问题。
Get-ChildItem -Filter %s -Recurse | Select-Object @{l='WAV File';e={Split-Path -noQualifier ($_.FullName) }} | Format-List -Wrap 这个不对到底怎么换行
如果你想在 Java 中执行 PowerShell 的 `Get-ChildItem` 命令,并使输出以换行的方式显示,你可以尝试以下方法:
```java
ProcessBuilder processBuilder = new ProcessBuilder("powershell.exe", "-Command", "Get-ChildItem -Filter %s -Recurse | Select-Object @{l='WAV File';e={Split-Path -noQualifier ($_.FullName) }} | Format-List");
// 替换 %s 为你的过滤条件
String filter = "your_filter";
String command = String.format(processBuilder.command().get(2), filter);
processBuilder.command().set(2, command);
Process process = processBuilder.start();
// 使用 BufferedReader 逐行读取输出
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
process.waitFor();
```
在上面的代码中,我们使用 `String.format()` 方法将过滤条件 `%s` 替换为你的实际过滤条件。然后,使用 `BufferedReader` 逐行读取 PowerShell 命令的输出,并在 Java 中进行打印。
这样,输出将以换行的方式显示。希望这可以帮助到你。如果还有其他问题,请随时提问。