Skip to content

SELECT DISTINCT and ORDER BY not working #756

Open

Description

@cbugari

Hi good day.
I have the following problem using the following statement alasql

var sql = 'select DISTINCT FROM Period? ORDER BY ASC RequestDate '
var res = alasql (sql, [result]);

With version 0.3 (used in the example), it does not work correctly the DISTINCT, but if the ORDER BY.
With version 0.2.1 (which I use in my project, it works well but not the DISTINCT ORDER BY.
There is a report on DISTINCT malfunction in version 3.
Thank you so much.

NOTE: The sample data are online

<!DOCTYPE html>

<html lang="en">
<script src="https://cdn.jsdelivr.net/alasql/0.3/alasql.min.js"></script> 
<script  src="https://code.jquery.com/jquery-3.1.1.min.js" type="text/javascript"></script>
<body>
    Query result: <div id="result"></div>
</body>

<script>  
$.ajax({
            type: "POST",
            url: "http://databoard.com.ar/COCA/WS_select_SLA_Grafico1.php?var1=&var2=&var3=OLA%20outline%20agreement&var4=&var5=&var6=&var7=&var8=&var9=&var10=",
            dataType: 'jsonp',
            async: true,
            dataF: "{}", 
            success: function (result) {

            var sql = 'select DISTINCT Period FROM ? ORDER BY RequestDate ASC'
            var res = alasql(sql , [result]);

            document.getElementById("result").innerHTML = JSON.stringify(res);
        }

})
</script>
</html>



Activity

  1. cbugari commented on Sep 26, 2016

    @cbugari
    Author

    Sorry, the correct query is:

    var sql = 'select DISTINCT Period FROM ? ORDER BY ASC RequestDate '
    var res = alasql (sql, [result]);

  2. mathiasrw commented on Sep 30, 2016

    @mathiasrw
    Member

    Hi @cbugari - Sorry long response time.

    Thank you so much for a very well described bug.

    Its really terrible we have introduced an error - but even worse that our regression tests did not include this scenario.

    Small questions - if we have data corresponding to

    {
            "RequestDate": "2015-09-17",
            "Period": "Sep-15"
        },
        {
            "RequestDate": "2015-09-18",
            "Period": "Sep-15"
        },
        {
            "RequestDate": "2015-09-17",
            "Period": "Jul-16"
        },
        {
            "RequestDate": "2015-09-18",
            "Period": "Jul-16"
        }
    

    will you the expect jul-16 or sep-16 to come first?

    This is really

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions