SQL Distinct

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nicolas

    #1

    SQL Distinct

    What should be the SQL Query syntax to get the result:
    Basicaly it's a dinstinct on "Name" but the DocUNID is always quicking in

    Query not working: SELECT DISTINCT sysEnum.Name, sysEnum.docUNID FROM
    sysEnum ORDER BY sysEnum.Name ASC;

    Desired Results:
    {F77A1DCD-3948-4761-B38F-C5DD0A823196} ListType
    {CC626E01-A3AE-444B-BB89-075DEF192725} Module
    {7928EE15-C6B2-4F53-B9C9-7B8BED227574} UserType




    Here is the table "sysEnum"
    DOCUNID
    Name

    {F77A1DCD-3948-4761-B38F-C5DD0A823196} ListType
    {E0F887EA-7573-4D00-9DE2-43D68435F9CB} ListType
    {BB83F135-608E-4104-A5A4-2E1D26AEE6DA} ListType
    {CC626E01-A3AE-444B-BB89-075DEF192725} Module
    {3C6A6B47-1DCE-42CB-8859-66D6BAB479B5} Module
    {CF7678C2-39BE-4A7A-9695-48445C99C8FF} Module
    {7928EE15-C6B2-4F53-B9C9-7B8BED227574} UserType
    {0E3AA5C8-953F-4146-A7EB-92164100C67A} UserType
    {942CCCB1-CBCB-4B47-8BA6-EF34CEA1DA03} UserType
    {5CA375D8-87ED-4FE3-83B9-4098CC3AB73E} UserType


    Thanks for the help
    Nicolas


  • Armin Zingler

    #2
    Re: SQL Distinct

    "Nicolas" <nliebel@hotmai l.com> schrieb[color=blue]
    > What should be the SQL Query syntax to get the result:
    > Basicaly it's a dinstinct on "Name" but the DocUNID is always
    > quicking in
    >
    > Query not working: SELECT DISTINCT sysEnum.Name, sysEnum.docUNID
    > FROM sysEnum ORDER BY sysEnum.Name ASC;
    >
    > Desired Results:
    > {F77A1DCD-3948-4761-B38F-C5DD0A823196} ListType
    > {CC626E01-A3AE-444B-BB89-075DEF192725} Module
    > {7928EE15-C6B2-4F53-B9C9-7B8BED227574} UserType
    >
    >
    >
    >
    > Here is the table "sysEnum"
    > DOCUNID
    > Name
    >
    > {F77A1DCD-3948-4761-B38F-C5DD0A823196} ListType
    > {E0F887EA-7573-4D00-9DE2-43D68435F9CB} ListType
    > {BB83F135-608E-4104-A5A4-2E1D26AEE6DA} ListType
    > {CC626E01-A3AE-444B-BB89-075DEF192725} Module
    > {3C6A6B47-1DCE-42CB-8859-66D6BAB479B5} Module
    > {CF7678C2-39BE-4A7A-9695-48445C99C8FF} Module
    > {7928EE15-C6B2-4F53-B9C9-7B8BED227574} UserType
    > {0E3AA5C8-953F-4146-A7EB-92164100C67A} UserType
    > {942CCCB1-CBCB-4B47-8BA6-EF34CEA1DA03} UserType
    > {5CA375D8-87ED-4FE3-83B9-4098CC3AB73E} UserType[/color]


    Actually this is a SQL question, not a VB.Net question, but...


    Why is it

    {F77A1DCD-3948-4761-B38F-C5DD0A823196} ListType

    not

    {E0F887EA-7573-4D00-9DE2-43D68435F9CB} ListType

    ?


    Armin


    Comment

    • Nicolas

      #3
      Re: SQL Distinct

      This is an enumrator table so I got one table for the enumator per say and
      another table with the enumerator name that is is to be use with custom
      globalization for title


      This should list the type of enumerator
      DocUNID
      Name DefaultValue en
      fr es
      {F77A1DCD-3948-4761-B38F-C5DD0A823196} ListType
      "ListType" Type of List Type de liste
      {CC626E01-A3AE-444B-BB89-075DEF192725} Module
      "ModuleList " List of Module Liste de modules


      This is the global Table for all enumerator
      Then I got the other table for those enum
      DocUNID
      Name ID DefaultValue en
      fr es
      {F77A1DCD-3948-4761-B38F-C5DD0A823196} ListType 0
      Item1
      {E0F887EA-7573-4D00-9DE2-43D68435F9CB} ListType 1
      Item2
      {BB83F135-608E-4104-A5A4-2E1D26AEE6DA} ListType 2
      Item2
      {CC626E01-A3AE-444B-BB89-075DEF192725} Module 0
      Module1
      {3C6A6B47-1DCE-42CB-8859-66D6BAB479B5} Module 1
      Module2
      {CF7678C2-39BE-4A7A-9695-48445C99C8FF} Module 2
      Module3



      "Armin Zingler" <az.nospam@free net.de> wrote in message
      news:urxf81fTGH A.1868@TK2MSFTN GP09.phx.gbl...[color=blue]
      > "Nicolas" <nliebel@hotmai l.com> schrieb[color=green]
      > > What should be the SQL Query syntax to get the result:
      > > Basicaly it's a dinstinct on "Name" but the DocUNID is always
      > > quicking in
      > >
      > > Query not working: SELECT DISTINCT sysEnum.Name, sysEnum.docUNID
      > > FROM sysEnum ORDER BY sysEnum.Name ASC;
      > >
      > > Desired Results:
      > > {F77A1DCD-3948-4761-B38F-C5DD0A823196} ListType
      > > {CC626E01-A3AE-444B-BB89-075DEF192725} Module
      > > {7928EE15-C6B2-4F53-B9C9-7B8BED227574} UserType
      > >
      > >
      > >
      > >
      > > Here is the table "sysEnum"
      > > DOCUNID
      > > Name
      > >
      > > {F77A1DCD-3948-4761-B38F-C5DD0A823196} ListType
      > > {E0F887EA-7573-4D00-9DE2-43D68435F9CB} ListType
      > > {BB83F135-608E-4104-A5A4-2E1D26AEE6DA} ListType
      > > {CC626E01-A3AE-444B-BB89-075DEF192725} Module
      > > {3C6A6B47-1DCE-42CB-8859-66D6BAB479B5} Module
      > > {CF7678C2-39BE-4A7A-9695-48445C99C8FF} Module
      > > {7928EE15-C6B2-4F53-B9C9-7B8BED227574} UserType
      > > {0E3AA5C8-953F-4146-A7EB-92164100C67A} UserType
      > > {942CCCB1-CBCB-4B47-8BA6-EF34CEA1DA03} UserType
      > > {5CA375D8-87ED-4FE3-83B9-4098CC3AB73E} UserType[/color]
      >
      >
      > Actually this is a SQL question, not a VB.Net question, but...
      >
      >
      > Why is it
      >
      > {F77A1DCD-3948-4761-B38F-C5DD0A823196} ListType
      >
      > not
      >
      > {E0F887EA-7573-4D00-9DE2-43D68435F9CB} ListType
      >
      > ?
      >
      >
      > Armin
      >
      >[/color]


      Comment

      • Armin Zingler

        #4
        Re: SQL Distinct

        "Nicolas" <nliebel@hotmai l.com> schrieb im Newsbeitrag
        news:eVOEvJgTGH A.4308@TK2MSFTN GP10.phx.gbl...[color=blue]
        > This is an enumrator table so I got one table for the enumator per say and
        > another table with the enumerator name that is is to be use with custom
        > globalization for title
        >
        >
        > This should list the type of enumerator
        > DocUNID
        > Name DefaultValue en
        > fr es
        > {F77A1DCD-3948-4761-B38F-C5DD0A823196} ListType
        > "ListType" Type of List Type de liste
        > {CC626E01-A3AE-444B-BB89-075DEF192725} Module
        > "ModuleList " List of Module Liste de modules
        >
        >
        > This is the global Table for all enumerator
        > Then I got the other table for those enum
        > DocUNID
        > Name ID DefaultValue en
        > fr es
        > {F77A1DCD-3948-4761-B38F-C5DD0A823196} ListType 0
        > Item1
        > {E0F887EA-7573-4D00-9DE2-43D68435F9CB} ListType 1
        > Item2
        > {BB83F135-608E-4104-A5A4-2E1D26AEE6DA} ListType 2
        > Item2
        > {CC626E01-A3AE-444B-BB89-075DEF192725} Module 0
        > Module1
        > {3C6A6B47-1DCE-42CB-8859-66D6BAB479B5} Module 1
        > Module2
        > {CF7678C2-39BE-4A7A-9695-48445C99C8FF} Module 2
        > Module3
        >[/color]


        Sorry, but it's hard for me to recreate the columns from this posting. Also
        always use a fixed-width font in newsgroups. What ist the column DocUNID and
        what is Name?


        Armin

        Comment

        • Nicolas

          #5
          Re: SQL Distinct

          Thanks for try to help, I got the answer from another news group as you
          mention SQL newsgroup
          Here is the answer:

          SELECT Max(CAST(sysEnu m.DocUNID AS VARCHAR(50))), SysEnum.Name
          FROM sysEnum
          GROUP BY SysEnum.Name

          Nicolas

          "Armin Zingler" <az.nospam@free net.de> wrote in message
          news:OQC$RDmTGH A.4976@TK2MSFTN GP11.phx.gbl...[color=blue]
          > "Nicolas" <nliebel@hotmai l.com> schrieb im Newsbeitrag
          > news:eVOEvJgTGH A.4308@TK2MSFTN GP10.phx.gbl...[color=green]
          > > This is an enumrator table so I got one table for the enumator per say[/color][/color]
          and[color=blue][color=green]
          > > another table with the enumerator name that is is to be use with custom
          > > globalization for title
          > >
          > >
          > > This should list the type of enumerator
          > > DocUNID
          > > Name DefaultValue en
          > > fr es
          > > {F77A1DCD-3948-4761-B38F-C5DD0A823196} ListType
          > > "ListType" Type of List Type de[/color][/color]
          liste[color=blue][color=green]
          > > {CC626E01-A3AE-444B-BB89-075DEF192725} Module
          > > "ModuleList " List of Module Liste de modules
          > >
          > >
          > > This is the global Table for all enumerator
          > > Then I got the other table for those enum
          > > DocUNID
          > > Name ID DefaultValue en
          > > fr es
          > > {F77A1DCD-3948-4761-B38F-C5DD0A823196} ListType 0
          > > Item1
          > > {E0F887EA-7573-4D00-9DE2-43D68435F9CB} ListType 1
          > > Item2
          > > {BB83F135-608E-4104-A5A4-2E1D26AEE6DA} ListType 2
          > > Item2
          > > {CC626E01-A3AE-444B-BB89-075DEF192725} Module 0
          > > Module1
          > > {3C6A6B47-1DCE-42CB-8859-66D6BAB479B5} Module 1
          > > Module2
          > > {CF7678C2-39BE-4A7A-9695-48445C99C8FF} Module 2
          > > Module3
          > >[/color]
          >
          >
          > Sorry, but it's hard for me to recreate the columns from this posting.[/color]
          Also[color=blue]
          > always use a fixed-width font in newsgroups. What ist the column DocUNID[/color]
          and[color=blue]
          > what is Name?
          >
          >
          > Armin
          >[/color]


          Comment

          Working...