Results 1 to 3 of 3

Thread: Clause Group By

  1. #1
    Join Date
    Dec 2012
    Posts
    5

    Unanswered: Clause Group By

    Hi all, hope in your help.

    I try this sql query:
    Code:
    SELECT
    	[NAMES], [NUMBER]
    FROM
    	[CV].[dbo].[T40]
    WHERE
    	[NUMBER] = '44644'
    GROUP BY
    	[NAMES], [NUMBER];
    the output is:
    Code:
    NAMES		NUMBER	
    BENCORE S.R.L.	44644
    BENCORES.R.L.   44644
    I need instead this other output, can you help me?
    Code:
    NAMES		NUMBER	
    BENCORE S.R.L.	44644

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Why do you want to show "BENCORE S.R.L" and not "BENCORES.R.L" ??
    George
    Home | Blog

  3. #3
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    First of all, please consider this point.
    Quote Originally Posted by Wim View Post
    ...

    Two remarks:

    ...
    Second: surrounding object (column/schema/table) names with "[" and "]" makes your code less readable. Only do it when you have to, when an object name is a reserved word or contains spaces. When you are the one who can choose the names of the objects, never use reserved words or put spaces in them.

    Just my 2 cents.

    Then, How about these examples?
    (Not tested.)
    Code:
    SELECT MIN(NAMES) AS NAMES
         , NUMBER
     FROM  CV.dbo.T40
     WHERE NUMBER = '44644'
     GROUP BY
           NUMBER
    ;
    or

    Code:
    SELECT MIN(NAMES) AS NAMES
         , '44644'    AS NUMBER
     FROM  CV.dbo.T40
     WHERE NUMBER = '44644'
    ;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •