我有一个 T-SQL 查询,但很难将它转换为 android 的 SQLite,我有相同的表名、字段名、表结构和关系,任何帮助将不胜感激,下面是查询
SELECT
F.fieldID,F.name,F.description,F.sizeHA,F.sizeA
,F.owner,F.annualRent,F.latitude,F.longitude
,F.Farm_farmID,F.isActive,F.deactivationDate,F.areas,
(SELECT COUNT(DISTINCT LOWER(culture)) FROM Usages
WHERE Field_fieldID = F.fieldID
AND YEAR(date) = (SELECT TOP 1 YEAR(date) FROM Usages
ORDER BY Date DESC)
) as UsageCount
,(SELECT TOP 1 u.culture FROM Usages u WHERE u.Field_fieldID = F.fieldID
ORDER BY u.date desc) as culture
,(SELECT TOP 1 u.sort FROM Usages u WHERE u.Field_fieldID = F.fieldID
ORDER BY u.date desc) as sort
FROM Fields as F INNER JOIN Usages s on s.Field_fieldID = F.fieldID
GROUP BY F.fieldID,F.name,F.description,F.sizeHA,F.sizeA
,F.owner,F.annualRent,
F.latitude,F.longitude,F.Farm_farmID,F.isActive,F.deactivationDate,F.areas