Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8416975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:55:00+00:00 2026-06-10T01:55:00+00:00

One question about Postgresql selects. This works as it should: SELECT name,SUM(cash) FROM costumers

  • 0

One question about Postgresql selects. This works as it should:

SELECT 
  name,SUM(cash)
FROM 
  costumers
GROUP BY (name)

but how can I concat two (or more) fields in the GROUP BY clause?
This is what I tried:

SELECT 
  name,SUM(cash)
FROM 
  costumers
GROUP BY (name || ' ' || nickname)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:55:02+00:00Added an answer on June 10, 2026 at 1:55 am

    That will work, except that you need to select the expression you group by:

    SELECT 
        (name || ' ' || nickname) AS name_and_nickname,
        SUM(cash) AS total_cash
    FROM costumers
    GROUP BY (name || ' ' || nickname)
    

    Another option is to group by two fields by separating them with a comma:

    SELECT 
        name, nickname, SUM(cash) AS total_cash
    FROM costumers
    GROUP BY name, nickname
    

    Note that these two are not exactly equivalent. In particular these two rows will end up in the same group with the first version and in different groups in the second version:

    name    | nickname  | cash
    --------+-----------+----
    foo     | bar baz   | 10
    foo bar | baz       | 20
    

    The second option is probably what you mean.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my second question about clicking buttons in JavaScript but this one I'm
i answered one question about closures here in SO with this sample: function Constructor()
I had asked one question about this error before ( Android StackOverflowError in ViewGroup.resetResolvedTextDirection
i have one question about jQuery. If user select Presmerovanie with value 0 in
one question about PHP Development. I am building up some Form Fields for Calculations.
One question about protected constructor. I learnt that the protected constructor can be used
i have one question about jquery ajax().. I created a table grid and there
I have one question about searching and counting files in directories and subdirectories. I
I have one question about Yii framework, and I need your help. Basicly, I
now I am working with python. So one question about dict .... suppose I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.