<?php $do_not_duplicate[] = 0; ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
$category = get_the_category();
if (!in_array($category[0]->cat_ID, $do_not_duplicate)) :
$do_not_duplicate[] = $category[0]->cat_ID;
?>
<!--[HTML for show the posts]-->
<?php endif; ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>