how to generate view data from sql query? i need to create a view that display last post for each user to make them into carousel, i do many search but no pure response. than i will try to generate my view from this sql query:

SELECT *
FROM `node`
WHERE `type` = 'post'
AND `nid`
IN (
SELECT MAX( `nid` )
FROM `node`
WHERE `type` = 'post'
GROUP BY `uid`
)
LIMIT 0 , 30


Any Idea?
It looks like you're selecting 30 nodes of type 'post' and grouping them by user.  This view would be pretty easily built using the views UI. Once you've created the view, you should be able to add an author uid as a grouping field.  This will group the post fields by author.

Let me know if you have questions.