1054 - Unknown column 'pd.products_viewed' in 'order clause'
select p.products_id, p.products_image, p.products_price, p.products_date_available from (products p) left join products_to_categories p2c on p.products_id = p2c.products_id where p2c.categories_id = ''and p.products_status = '1' and p.products_date_available < 90 and p.products_date_available > 1 and p.products_image<>'' order by pd.products_viewed desc, p.products_id limit 3