I have this SQL table that looks like this

[![enter image description here](https://i.stack.imgur.com/oMuit.png)](https://i.stack.imgur.com/oMuit.png)

As you can see the Original Principal Balance is not ordered correctly. These variables are stored as a VARCHAR. How would I sort and order them correctly?

Here is my sql code:

```
WITH Original_Principal_Bal
AS (
    SELECT [New Loan Number]
        ,[Current Amortizing UPB]
        ,[Current Def UPB]
        ,sum([Current Amortizing UPB] + [Current Def UPB]) OVER (PARTITION BY Deal) AS [Total UPB]
        ,BPO
        ,[Current Rate]
        ,[Current Maturity]
        ,[Next Due Date]
        ,[First Payment Date]
        ,CASE 
            WHEN [Original Loan Amount] BETWEEN 0.01
                    AND 100000
                THEN '$0.01 to $100,000'
            WHEN [Original Loan Amount] BETWEEN 100000.01
                    AND 200000
                THEN '$100,000.01 to $200,000'
            WHEN [Original Loan Amount] BETWEEN 200000.01
                    AND 300000
                THEN '$200,000.01 to $300,000'
            WHEN [Original Loan Amount] BETWEEN 300000.01
                    AND 400000
                THEN '$300,000.01 to $400,000'
            WHEN [Original Loan Amount] BETWEEN 400000.01
                    AND 500000
                THEN '$400,000.01 to $500,000'
            WHEN [Original Loan Amount] BETWEEN 500000.01
                    AND 600000
                THEN '$500,000.01 to $600,000'
            WHEN [Original Loan Amount] BETWEEN 600000.01
                    AND 700000
                THEN '$600,000.01 to $700,000'
            WHEN [Original Loan Amount] BETWEEN 700000.01
                    AND 800000
                THEN '$700,000.01 to $800,000'
            WHEN [Original Loan Amount] BETWEEN 800000.01
                    AND 900000
                THEN '$800,000.01 to $900,000'
            WHEN [Original Loan Amount] BETWEEN 900000.01
                    AND 1000000
                THEN '$900,000.01 to $1,000,000'
            WHEN [Original Loan Amount] BETWEEN 1100000.01
                    AND 1200000
                THEN '$1,100,000.01 to $1,200,000'
            WHEN [Original Loan Amount] BETWEEN 1300000.01
                    AND 1400000
                THEN '$1,300,000.01 to $1,400,000'
            WHEN [Original Loan Amount] BETWEEN 1600000.01
                    AND 1700000
                THEN '$1,600,000.01 to $1,700,000'
            WHEN [Original Loan Amount] BETWEEN 1900000.01
                    AND 2000000
                THEN '$1,900,000.01 to $2,000,000'
            WHEN [Original Loan Amount] > 2000000.01
                THEN '$2,000,000 or greater'
            END AS [Original Principal Balance]
    FROM Portfolio_Analytics..Securitization_Tape
    )
SELECT [Original Principal Balance]
    ,COUNT([New Loan Number]) AS [Number of Mortgage Loans]
    ,ROUND(sum([Current Amortizing UPB] + [Current Def UPB]), 0) AS [Aggregate Unpaid Principal Balance as of Cut-off Date ($)]
    ,ROUND(avg([Current Amortizing UPB] + [Current Def UPB]), 0) AS [Average Unpaid Principal Balance ($)]
    ,ROUND(sum(([Current Amortizing UPB] + [Current Def UPB]) / [Total UPB]) * 100, 2) AS [Percetage of Aggregate Principal Balance as of Cut-off Date(%)]
    ,sum(BPO) AS [Aggregate Updated Value($)]
    ,ROUND(sum([Current Rate] * ([Current Amortizing UPB] + [Current Def UPB])) / sum([Current Amortizing UPB] + [Current Def UPB]), 2) AS [Weighted Average Mortgage Interest Rate(%)]
    ,ROUND(sum(([Current Amortizing UPB] + [Current Def UPB]) / bpo * ([Current Amortizing UPB] + [Current Def UPB])) / sum([Current Amortizing UPB] + [Current Def UPB]) * 100, 2) AS [Weighted Average Updated Loan-to-Value Ratio(%)]
    ,ROUND(sum((DATEDIFF(month, [Next Due Date], [Current Maturity]) + 1) * ([Current Amortizing UPB] + [Current Def UPB])) / (sum([Current Amortizing UPB] + [Current Def UPB])), 0) AS [Weighted Average Remaining Term to Maturity(Months)]
    ,ROUND(sum((DATEDIFF(month, [First Payment Date], [Next Due Date]) + 1) * ([Current Amortizing UPB] + [Current Def UPB])) / (sum([Current Amortizing UPB] + [Current Def UPB])), 0) AS [Weighted Average Remaining Term to Maturity(Months)]
FROM Original_Principal_Bal
GROUP BY [Original Principal Balance]

```

Perhaps I need to store the numbers differenly when I create the table, I am not sure how else to match what I want it to look like though.