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 8548951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:36:57+00:00 2026-06-11T13:36:57+00:00

I am selecting a name, an action and a count from Postgres sorting by

  • 0

I am selecting a name, an action and a count from Postgres sorting by name ASC, action ASC like so:

SELECT u.firstname || ' ' || u.surname AS user,
    nt.name AS action,
    cn.count
FROM (
    SELECT actioned_by_id, note_type_id, COUNT(id) AS count
    FROM customer_notes
    WHERE actioned_date IS NOT NULL 
    GROUP BY actioned_by_id, note_type_id
) AS cn
LEFT JOIN note_type AS nt ON cn.note_type_id = nt.id
LEFT JOIN users as u on cn.actioned_by_id = u.id
WHERE cn.actioned_by_id IS NOT NULL 
ORDER BY user, action;

however the results show that it is ignoring the user clause and only ordering by the action.

"ADMIN USER" "CALL OUT"   1
"ADMIN USER" "EMAIL"      1
"ADMIN USER" "LETTER"     2
"AA AA"      "MEETING"    1
"ADMIN USER" "PHONECALL"  7
"AA AA"      "PHONECALL"  1

Anyone understand why?
And how to make it order properly?

  • 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-11T13:36:58+00:00Added an answer on June 11, 2026 at 1:36 pm

    user is a reserved word – returning the current user name

    Try

    order by u.firstname || ' ' || u.surname, action
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm selecting a element with a certain name $('[name=lol]'] but there can be two
I'm selecting products from a database table. Currently the query is launched from Coldfusion,
I need help with selecting a li element when a user scrolls to a
I am having trouble selecting an item from a Javascript dropdown (i.e. the items
I have a html form which the user inputs values/selects options. After selecting, these
Imagine this simple form for uploading a file: <form action=upload enctype=multipart/form-data> <input type=text name=name/>
I have a very simple Project form with a name field and a select
I Have following in my struts.xml file <action name=ProductVerification class=com.frontend.ProductVerification> <result name=success>/jsp/product_verification.jsp</result> <result name=input>/jsp/product_verification.jsp</result>
I would like to validate the users choice of folder name in a gtk.FileChooser
Here I'm selecting the node: $ xmlstarlet sel -t -c /configuration/property[name='http.agent.name']/value conf/nutch-default.xml <value/> This

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.