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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:50:38+00:00 2026-05-27T04:50:38+00:00

This is what I have at the moment. $db =& JFactory::getDBO(); $query = $db->getQuery(true);

  • 0

This is what I have at the moment.

    $db =& JFactory::getDBO();

    $query = $db->getQuery(true);

    $query->select('`#__catalog_commit`.`id` as id, `#__catalog_commit`.`date` as date, COUNT(`#__catalog_commit_message`.`commit_id`) as count,
    (SELECT COUNT(`#__catalog_commit_message`.`type`) as count_notice FROM `#__catalog_commit_message` WHERE `#__catalog_commit_message`.`type` = 1 GROUP BY `#__catalog_commit_message`.`type`) as count_notice,
    (SELECT COUNT(`#__catalog_commit_message`.`type`) as count_warning FROM `#__catalog_commit_message` WHERE `#__catalog_commit_message`.`type` = 2 GROUP BY `#__catalog_commit_message`.`type`) as count_warning,
    (SELECT COUNT(`#__catalog_commit_message`.`type`) as count_error FROM `#__catalog_commit_message` WHERE `#__catalog_commit_message`.`type` = 3 GROUP BY `#__catalog_commit_message`.`type`) as count_error');
    $query->from('#__catalog_commit_message');
    $query->leftjoin('`#__catalog_commit` ON `#__catalog_commit`.`id` = `#__catalog_commit_message`.`commit_id`');
    $query->group('`#__catalog_commit_message`.`commit_id`');
    $query->order('`#__catalog_commit`.`id` DESC');

What I have is 2 tables with the following structures:

catalog_commit
==============
id
date

catalog_commit_message
======================
id
commit_id
type
message

Basically I want to have the count of each different types of messages per group items. In what I have it actually select every rows (Which is normal) but I’m looking for a way (nicier if possible) to have the count per messages type within the query.

EDIT: Just wanted to add that it’s a JModelList.

  • 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-05-27T04:50:38+00:00Added an answer on May 27, 2026 at 4:50 am

    From what I gather, this should be your query:

    SELECT c.id
          ,c.date
          ,count(cm.commit_id) as ct_total
          ,sum(CASE WHEN cm.type = 1 THEN 1 ELSE 0 END) AS count_notice
          ,sum(CASE WHEN cm.type = 2 THEN 1 ELSE 0 END) AS count_warning
          ,sum(CASE WHEN cm.type = 3 THEN 1 ELSE 0 END) AS count_error
    FROM   catalog_commit c 
    LEFT   JOIN catalog_commit_message cm ON cm.commit_id = c.id
    GROUP  BY c.id, c.date
    ORDER  BY c.id DESC
    

    You had the order of your tables reversed in the LEFT JOIN. Also, you had weird subqueries in the SELECT list.

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

Sidebar

Related Questions

I have this script at the moment, which changes an image when a thumbnail
This is what I have at the moment. <h2>Information</h2>\n +<p>(.*)<br />|</p> ^ that is
I have two nested loop in XSL like this, at this moment I use
I have this at the moment, (I found the code on here). var exp
I have this at the moment: (the list is longer, but this is just
I have this working ok(ish) in my game at the moment, but i'm not
At the moment, I have this run of code: <%=h current_user.notes.collect { |t| t.name
UPDATE 4: This is what I have at the moment: var $elements = $('.dropdown');
At the moment I have this to check whether the $content is containing youtube
At the moment I have this Code (Deepth = 2 Categories) private void Window_Loaded(object

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.