我有以下SQL(请注意使用distinct
):
SELECT DISTINCT
question_id AS id,
question_id AS object_id,
created_at AS created,
created_at AS lastmessage,
'T' AS object_type
FROM
responses
...这给了我...
我想摆脱第一列中的重复行。我想念什么?
答案 0 :(得分:1)
如果要每行一行,请使用聚合。像这样:
SELECT question_id AS id, question_id AS object_id,
MIN(created_at) AS created,
MAX(created_at) AS lastmessage,
'T' AS object_type
FROM responses
GROUP BY question_id;