question

pyeolla avatar image
pyeolla asked

Flags with different granularity SQL

I'd like to say that I'm still learning how to use SQL so what I am asking might be very easy for some of you.

So, let's suppose that I have a column called SAMPLE, and one column called BATCH. Also, a BATCH contains a few SAMPLEs and for some reason there is a flag linked to the SAMPLE column (SAMPLE_FLG).

The BATLCH_FLG is there to show that at least one of the samples contained in that batch was flagged as 1.

You can visualize this scenario in the following table:

img.jpg

How can I obtain with a SQL query just a single 1 for each batch in the BATCH_FLG column?

What I mean is that I shouldn't have 1 multiple times even if more than one sample for each batch is flagged as 1 (such as in the last three rows).

The position of the 1 in the BATCH_FLG column is not important.


I hope you can help me.

Thank you.

mysqlsql querysqlquery
img.jpg (51.0 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.