Home Forums SQL Server 7,2000 T-SQL GROUP BY vs DISTINCT -- SQL SERVER BUG ? RE: GROUP BY vs DISTINCT -- SQL SERVER BUG ?

  • Hi Peter,

    I don't think that Julian's claim is correct. For example

    select left (filename, 1) as drive from master.dbo.sysaltfiles

    group by left (filename, 1)

    order by 1 

    will yield the same result as

    select distinct left (filename, 1) as drive from master.dbo.sysaltfiles

    --group by left (filename, 1)

    order by 1

    If one omits the group by clause in the first example one will get one line for each file on the drive.

    So, if you say, both of your queries provide the same number of records what is the difference anyway? Obviously I do miss the point of your problem. It seems to have to do with the function you are using. SQL Server does not detect any difference when you call them with different string constants as you have tried unsuccesful even though the select will provide different return values of the function. Try to test a different set of function rather than controling their behaviour by string constants. In this case your attempt should work.

    Karsten