How to change the query for content type in d6 to d7?
You should add a new view by the UI. Then, you can display the generated SQL query, by activating the sql display below the views UI:

admin/build/views/tools (D6)
admin/structure/views/settings (D7)




You'll see live, what the sql query is :



Copy/Paste the sql and rearrange it