Dev*_*ate 1 sql intersystems-cache
这是我目前的查询:
SELECT TOP 6 *
FROM HS_IHE_ATNA_Repository.Aggregation
WHERE EventType = 'Retrieve Document Set'
Run Code Online (Sandbox Code Playgroud)
它返回看起来类似于此的数据:
ID TimeStamp tid Fruit Color User EventType
1 12:30:31 001 Apple Red Paul Retrieve Document Set
2 12:30:32 001 Apple Red Paul Retrieve Document Set
3 12:31:03 002 Orange Orange Steve Retrieve Document Set
4 12:31:04 002 Orange Orange Steve Retrieve Document Set
5 12:34:12 003 Banana Yellow Paul Retrieve Document Set
6 12:34:13 003 Banana Yellow Paul Retrieve Document Set
Run Code Online (Sandbox Code Playgroud)
我希望我的查询只返回记录1,3和5.基本上,所有东西都有一个独特的tid.我怎样才能做到这一点?
尝试:
SELECT distinct(*)
FROM HS_IHE_ATNA_Repository.Aggregation a
WHERE EventType = 'Retrieve Document Set'
AND TimeStamp = (select min(b.TimeStamp) from from HS_IHE_ATNA_Repository.Aggregation b
WHERE b.tid = a.tid)
ORDER BY ID asc
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1056 次 |
| 最近记录: |