MYSTERY ZILLION တွင် English သို့မဟုတ် Unicode ဖြင့်သာ အသုံးပြုခွင့်ရှိသည်။ ဇော်ဂျီ ၊ ဧရာ စသည်တို့ကို အသုံးပြုခွင့် မရှိ။ Unicode fonts များမှာ Mon3,Yunghkio, Myanamr3 စသည်များ အသုံးပြုနိုင်သည်။ Unicode Guide ကို ဒီမှာ Download ချပါ။ Zawgyi to Unicode Converter
Don't share ebook or software if nobody request. You can find free book websites on here. We are welcome for discussion or asking question instead.

DESC problem

edited December 2013 in Database

ဒီ Querry အတိုင်း သုံးတာ ဘာတွေ ဖြစ်နေလဲမသီတောဘူး..........
ကြီးစဉ်ငယ်လိုက်မထွက်တောဘူး........

SELECT Distinct CurrentStatus,Appliedpp_ID,DEO_No as [Doc No],Name,Convert(varchar(10),Date_Of_Birth,103) as [Date Of Birth],place_of_birth as [Place Of Birth],Sex,PP_Type as [Passport Type],Passport_No as [Passport Number],Convert(varchar(20),Date_Of_Issue,103) as [Date Of Issue],Convert(varchar(10),Date_Of_Expiry,103) as [Date Of Expiry],Convert(varchar(10),Printed_Date,103) as [Printed Date],Old_Passport_No as [Old Passport No] from v_printed Where IsDeleted=0 and IsLocked=0 and Is_Active=1 and currentstatus='8' and ApproveBy='SB' AND Is_Active=1 and is_printed=0  Order By AppliedPP_ID DESC

မှတ်ချက်များ

  • Administrators

    What is the Appliedpp_ID data type ? Is it integer ?

  • edited December 2013 Administrators

    စောစောက အဖြေကိုပြန်ဖျက်ထားတယ် ပုံကစောစောက မမြင်ရဘူး ပုံထဲမှာက Appliedapp_ID က Sort လုပ်ထားပါတယ် ကြည့်ရတာ Character ဖြစ်နေတယ် Numeric မဟုတ်တဲ့အတွက် character အနေနဲ့ sort လုပ်နေတာပါ Numeric Datatype တခုပြောင်းလိုက်ရင် လိုချင်တဲ့အတိုင်း ရပါလိမ့်မယ်။

  • Registered Users

    yes,Appliedpp_ID is integer

  • edited December 2013 Administrators

    Please confirm your datatype in table schema. I do believe, current data type is character.

  • Registered Users

    brother mean current status .Yes,Current status is Character

  • edited December 2013 Registered Users

    your Querry is ok but next Query is not ok.the next querry is

    Select * from (Select Distinct CurrentStatus,Appliedpp_ID,DEO_No,Name,Convert(varchar(10),Date_Of_Birth,103) as [Date Of Birth],place_of_birth as [Place Of Birth],Sex,PP_Type as [Passport Type],Passport_No as [Passport Number],Convert(varchar(20),Date_Of_Issue,103) as [Date Of Issue],Convert(varchar(10),Date_Of_Expiry,103) as [Date Of Expiry],Convert(varchar(10),Printed_Date,103) as [Printed Date],Old_Passport_No as [Old Passport No] from v_printed Where IsDeleted=0 and IsLocked=0 and Is_Active=1 and currentstatus='8' and ApproveBy='SB' AND Is_Active=1And Printed_Date = '2013-12-11' and is_printed=1 ) as t1 Order By  DEO_No DESC
    

  • Administrators

    can you show the data type screen shot ?

  • edited December 2013 Registered Users

    Not related to your question.
    But I don't understand why first part "SELECT * FROM ..." is required.

    If this is a complete query, can it be done like below?

    SELECT DISTINCT CurrentStatus,Appliedpp_ID, ... FROM v_printed WHERE ... ORDER BY DEO_No DESC
  • edited December 2013 Registered Users

    Your column 'Deo_No' is string type (varchar or nvarchar).
    That's why you cannot sort correctly.

    If you really need it, you can sort by using substring and type casting together like below.

    SELECT DISTINCT 
              CurrentStatus,
              Appliedpp_ID,
              DEO_No,
              Name,
              Convert(varchar(10),
              Date_Of_Birth,103) AS [Date Of Birth],
              place_of_birth as [Place Of Birth],
              Sex,
              PP_Type as [Passport Type],
              Passport_No as [Passport Number],
              Convert(varchar(20),
              Date_Of_Issue,103) as [Date Of Issue],
              Convert(varchar(10),Date_Of_Expiry,103) as [Date Of Expiry],
              Convert(varchar(10),Printed_Date,103) as [Printed Date],
              Old_Passport_No as [Old Passport No]
    FROM 
              v_printed
    WHERE 
              IsDeleted=0
              AND IsLocked=0
              AND Is_Active=1
              AND currentstatus='8'
              AND ApproveBy='SB'
              AND Is_Active=1
              AND Printed_Date = '2013-12-11'
              AND is_printed=1
    ORDER BY 
              CAST(SUBSTRING(DEO_No,9,2) AS INT) DESC

    This will work only if all your DEO_No data are in the format of xxxx_xx_xx. (e.g. MYS3_13_10)

    If not, you may need to change accordingly.

    I.e. "MYS31_123_11" will not work.

    If you can use another number-type column to sort, it should be the best.

    Because substring and type casting may impact your query performance while you already have multiple criterias defined.

  • Registered Users

    Tnank a lot .......နောက်လဲဖြေပေးကြပါအုန်း....အခက်ခဲရှိတိုင်း ဒီSite ပဲမေးနေရတာ.....

  • edited December 2013 Administrators

    Have you checked your table schema? So far, you do not understand the differences of character and numeric. That is more important than getting the working query for you.

Sign In or Register to comment.