error in sql query using sorting

Posted by Klbaiju under Sql Server on 8/30/2012 | Points: 10 | Views : 882 | Status : [Member] | Replies : 1
hi

this is my sql query

select distinct nf.NFO_Close as NFO_Close,s.DURATION_DAYS,nf.ID ,s.Fund_Name ,s.masterScheme_id,a.ID as AMC_ID,a.AMC_NAME,
sc.id AS SCHEME_CAT_ID,sc.CATEGORY_NAME,st.id as SCHEME_TYPE_ID,
st.Scheme_Type,nf.NFO_Open,TMS.MIN_AMOUNT_PURCHASE
from nfoscheme as nf inner join SCHEME as s on nf.SCHEME_ID=s.masterScheme_id
left join amc as a on s.AMC_ID=a.id
left join scheme_category sc on s.Scheme_Category_id=sc.id
left join schemetype st on s.SCHEME_TYPE_ID =st.id
left JOIN TERMS TMS ON TMS.SCHEME_ID= S.id WHERE NF.SCHEME_ID=S.ID and NF.status='ACTIVE' order by NFO_Close desc

i want to sort s.fund_name.



i add a comma and put s.fund_name but not working



how to solve this



regards

Baiju




Responses

Posted by: Pandians on: 8/30/2012 [Member] [MVP] Silver | Points: 25

Up
0
Down
Its depend on your data!

and, you have used the table "SCHEME" in LEFT JOIN.

If data not matching with "nfoscheme" table then you'll get NULL for "s.Fund_Name" column, So, It'll be sorted by NULL!

So, It'll never use!

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response