Отвечено Order by View

Все ответы

  • 13 марта 2012 г. 13:18
     
     

    Hello,

    You can order by that column, even if it contains NULL values. So where is exactly the problem?


    Olaf Helper
    * cogito ergo sum * errare humanum est * quote erat demonstrandum *
    Wenn ich denke, ist das ein Fehler und das beweise ich täglich
    Blog Xing

  • 13 марта 2012 г. 13:27
     
     

    The problem is this, see the example
    Name  | Phone
       A     | 555 555
      null   | 666666
       A     | 777 777
       B     | 555 555

    This [null] should not appear. It should be ordered as follows:
    . A
    . A
    . B


    • Изменено Bruno.Costa 13 марта 2012 г. 13:28
    •  
  • 13 марта 2012 г. 13:36
     
     Предложенный ответ С кодом

    If you do not want those NULLS then simply restrict them using the where clause !  that is what the where clause works.

     Try

     

    CREATE TABLE YOURTABLE(NAME VARCHAR(10), PHONE VARCHAR(20))

    INSERT INTO YOURTABLE VALUES('A',12121) INSERT INTO YOURTABLE VALUES('B',12122) INSERT INTO YOURTABLE VALUES(NULL,12124)

    SELECT Name,Phone FROM YOURTABLE WHERE NAME IS NOT NULL ORDER BY NAME



    Thanks
    Manish

    Please use Mark as Answer if my post solved your problem and use Vote As Helpful if a post was useful.

    • Предложено в качестве ответа Lalith Sarika 13 марта 2012 г. 22:19
    •  
  • 13 марта 2012 г. 13:39
     
     
    the problem that if you run the select from view within SSMS, the fields do not appear nulls.
    they appear only in view of the report.
  • 20 марта 2012 г. 2:23
    Модератор
     
     Отвечено
    Hi Bruno,

    In your case, I think that we can add a filter to eliminate null values on the report level and then sort the report column. For example, we can add a filter like this:
    Expression: =IsNothing(Fields!Name.Value)OR (Fields!Name.Value="")
    Operator: =
    Value: =False

    For more information, please see:
    Add a Filter: http://technet.microsoft.com/en-us/library/ms156270(v=sql.100).aspx
    Sort Data in a Data Region: http://technet.microsoft.com/en-us/library/ms157462(v=sql.100).aspx

    Regards,
    Bin Long

    Bin Long

    TechNet Community Support