Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Distinct and Top 10

Author  Topic 

dhinasql
Posting Yak Master

195 Posts

Posted - 2008-07-03 : 11:07:04
Hi Friends,

I have the follwoing query when i execute this im getting the following error, please rectify this error and i want to select only top 10 rows

ORDER BY items must appear in the select list if SELECT DISTINCT is specified.

SELECT distinct p.prty_plan, p.prty_id, p.prty_genid,p.City,p.prty_Type,p.prty_SqrFootage,p.Prty_NoOfBedRooms,p.prty_Price,p.prty_status,f.fav_status
FROM tbl_property p
left JOIN tbl_favorites f ON p.prty_id = f.prty_id and f.user_id=13 where prty_deleted=0 order by prty_creationDateTime desc

Please help me and its very urgent please

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-07-03 : 11:11:35
quote:
Originally posted by dhinasql

Hi Friends,

I have the follwoing query when i execute this im getting the following error, please rectify this error and i want to select only top 10 rows

ORDER BY items must appear in the select list if SELECT DISTINCT is specified.

SELECT distinct p.prty_plan, p.prty_id, p.prty_genid,p.City,p.prty_Type,p.prty_SqrFootage,p.Prty_NoOfBedRooms,p.prty_Price,p.prty_status,f.fav_status
FROM tbl_property p
left JOIN tbl_favorites f ON p.prty_id = f.prty_id and f.user_id=13 where prty_deleted=0 order by prty_creationDateTime desc

Please help me and its very urgent please



Answer is in error.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-03 : 13:44:49
quote:
Originally posted by sodeep

quote:
Originally posted by dhinasql

Hi Friends,

I have the follwoing query when i execute this im getting the following error, please rectify this error and i want to select only top 10 rows

ORDER BY items must appear in the select list if SELECT DISTINCT is specified.

SELECT distinct p.prty_plan, p.prty_id, p.prty_genid,p.City,p.prty_Type,p.prty_SqrFootage,p.Prty_NoOfBedRooms,p.prty_Price,p.prty_status,f.fav_status
FROM tbl_property p
left JOIN tbl_favorites f ON p.prty_id = f.prty_id and f.user_id=13 where prty_deleted=0 order by prty_creationDateTime desc

Please help me and its very urgent please



Answer is in error.



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -