create table events
(
sensor_id integer not null,
event_type integer not null,
value integer not null,
time timestamp unique not null
);
表我想是展現獨特的條目,並採取具有最長時間的條目,我寫了這個查詢
SELECT B.*
FROM events AS B
RIGHT JOIN (SELECT DISTINCT sensor_id, event_type, MAX(time) AS MaxDateTime
FROM events
GROUP BY sensor_id, event_type
ORDER BY MAxDateTime DESC) A ON B.time = A.MaxDateTime
我想要的是跳過時間列,只顯示最終結果中的sensor_id,event_type和值,有什麼想法?
變化'灣*''到B.sensor_ID,B.event_Type,B.Value' – xQbert
但後來怎麼樣B.time = A.MaxDateTime? – mohsinali1317
這就是加入批評。我想你會想加入,sensor_Id和event_Type ......時間將不會顯示,只有選擇內容會是什麼。 – xQbert