Custom Select Query pagination not working properly

I found solution. Grouping duplicated posts by ID. Just add this code to select query:

GROUP BY wp_posts.ID 

Whole code (maybe it will help someone – not many examples of working pagination with select query around the internet :)):

<?php
global $wpdb;
$date = date("Y-m-d");
$querystr = "
SELECT * 
FROM wp_posts
JOIN wp_ftcalendar_events ON wp_posts.ID = wp_ftcalendar_events.post_parent
WHERE wp_posts.post_status="publish"
AND wp_posts.post_type="post"
AND wp_ftcalendar_events.start_datetime < '$date'
GROUP BY wp_posts.ID 
ORDER BY wp_ftcalendar_events.start_datetime DESC 
 ";

$total_record = count($wpdb->get_results($querystr, OBJECT_K));

$paged      = get_query_var('paged') ? get_query_var('paged') : 1;
$post_per_page  = 3;
$offset         = ($paged - 1)*$post_per_page;
$max_num_pages  = ceil($total_record/ $post_per_page);

$wp_query->found_posts = $total_record;
$wp_query->max_num_pages = $max_num_pages;

$limit_query    =   " LIMIT ".$post_per_page." OFFSET ".$offset;  

$pageposts =   $wpdb->get_results($querystr.$limit_query, OBJECT_K); ?>

 <?php if ($pageposts): ?>

  <?php global $post; ?>

  <?php foreach ($pageposts as $post): ?>

      <?php setup_postdata($post); ?>

      <!-- do stuff -->

 <?php endforeach; ?>

 <?php endif; ?>

 <?php if(function_exists('wp_paginate')) { wp_paginate(); }    ?>