有2个表S、C,
S有字段sId(主键), sName, C有字段cId(主键)、sId(外键)、cTime
假设S数据为:
sId, sName
a, 哈
b, 呵
C数据为:
cId, sId, cTime, cValue
1, a, 100, xxx
2, a, 111, yyy
3, b, 123, zzz
4, b, 234, hhh
现在我要查询的结果为:
sId , sName, cTime, cValue
a, 哈, 111, yyy
b, 呵, 234, hhh
请问这个sql语句该怎么写?
sqlite查询语句怎么写
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
3条回答 默认 最新
threenewbee 2016-02-26 14:00关注select S.sId, S.sName, Max(c.cTime), Max(c.cValue) from S join C on S.sId = C.sId group by C.sId解决 无用评论 打赏 举报