--SQL语句:一种连接本表2个查询结果的复杂sql语句、一种查找一列有重复值的语句
--数据库test的imagestore表包含以下字段:
--autoId,stationId,cardIndex,directionIndex,captureTime,uploadTime,roadImage
USE test
GO
SELECT * FROM imagestore
WHERE capturetime = (SELECT MAX(capturetime) FROM imagestore WHERE stationid = 1002 and directionindex =1)
and stationID = 1002 and directionindex = 1
UNION ALL
SELECT * FROM imagestore
WHERE capturetime = (SELECT MAX(capturetime) FROM imagestore WHERE stationid = 1002 and directionindex =3)
and stationID = 1002 and directionindex = 3
GO
SELECT * FROM imagestore where stationId in (SELECT stationId FROM imagestore GROUP BY stationId HAVING(COUNT(*) > 1))
GO