I hope I can explain this properly. This is what the result of the table looks like
Content_IDs of 4,5,6 are NEWS. As long as there is one boolean of true the column IsContentUpdated for NEWS, I'd like the distinct NEWS boolean to be true otherwise false.
Ultimately what I'd just want to get is
I tried with a temp table with a count of IsContentUpdated but it didn't work very well. I'm kind of convinced I shouldn't need a temp table but am having a brain cramp trying to think what I can do here.
Any help is greatly appreciated. Thanks!
not sure I understand well, but if what you wanna get is what you show, it should be
SELECT Page_ID, MAX(CAST(IsContentUpdated AS INT))
FROM Table
GROUP BY Page_ID
This will give you a distinct list of the Page_ID
s and whether or not any of them have a IsContentUpdated = 1
:
select distinct Page_ID, max(IsContentUpdated)
from myTable
group by Page_ID
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.