0

This is my first post here.

My question is, how to combine row when timestamp (base on date only Y-m-d), item_condition and equipment_spare_id are same. Then GROUP_CONCAT remark and serial_number.

In this case, it should has 2 row.

Thanks in advance.

image

2
  • Please edit your question and post the expected result as table. Commented Sep 14, 2019 at 14:10
  • Sure. I will will update it asap. Commented Sep 14, 2019 at 14:49

2 Answers 2

1

You seem to want group by. You are not clear on what the result set should look like, but the idea is:

select date(timestamp) as dte, item_condition, equipment_spare_id,
       count(*)
from t
group by dte, item_condition, equipment_spare_id;
Sign up to request clarification or add additional context in comments.

Comments

1

You can use GROUP BY and GROUP_CONCAT as follows:

SELECT 
    date(timestamp) as dte, 
    item_condition, 
    equipment_spare_id,
    GROUP_CONCAT(remark) all_remarks,
    GROUP_CONCAT(serial_number) all_serials
FROM mytable
GROUP BY 
    date(timestamp), 
    item_condition, 
    equipment_spare_id

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.