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

  • Home
  • SEARCH
  • 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 1107925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:00:20+00:00 2026-05-17T02:00:20+00:00

I have a simple report sending framework that basically does the following things: It

  • 0

I have a simple report sending framework that basically does the following things:
It performs a SELECT query, it makes some text-formatted tables based on the results, it sends an e-mail, and it performs an UPDATE query.

This system is a generalization of an older one, in which all of the operations were hard coded. However, in pushing all of the logic of what I’d like to do into the SELECT query, I’ve run across a problem.

Before, I could get most of the information for my text tables by saying:

SELECT Name, Address FROM Databas.Tabl WHERE Status='URGENT';

Then, when I needed an extra number for the e-mail, also do:

SELECT COUNT(*) FROM Databas.Tabl WHERE Status='URGENT' AND TimeLogged='Noon';

Now, I no longer have the luxury of multiple SELECT queries. What I’d like to do is something like:

SELECT Tabl.Name, Tabl.Address, COUNT(Results.UID) AS Totals
FROM Databas.Tabl
LEFT JOIN Databas.Tabl Results
    ON Tabl.UID = Results.UID
    AND Results.TimeLogged='Noon'
WHERE Status='URGENT';

This, at least in my head, says to get a total count of all the rows that were SELECTed and also have some conditional.

In reality, though, this gives me the “1140 – Mixing of GROUP columns with no GROUP columns illegal if no GROUP BY” error. The problem is, I don’t want to GROUP BY. I want this COUNT to redundantly repeat the number of results that SELECT found whose TimeLogged=’Noon’. Or I want to remove the AND clause and include, as a column in the result of the SELECT statement, the number of results that that SELECT statement found.

GROUP BY is not the answer, because that causes it to get the COUNT of only the rows who have the same value in some column. And COUNT might not even be the way to go about this, although it’s what comes to mind. FOUND_ROWS() won’t do the trick, since it needs to be part of a secondary query, and I only get one (plus there’s no LIMIT involved), and ROW_COUNT() doesn’t seem to work since it’s a SELECT statement.

I may be approaching it from the wrong angle entirely. But what I want to do is get COUNT-type information about the results of a SELECT query, as well as all the other information that the SELECT query returned, in one single query.

=== Here’s what I’ve got so far ===

SELECT Tabl.Name, Tabl.Address, Results.Totals
FROM Databas.Tabl
LEFT JOIN (SELECT COUNT(*) AS Totals, 0 AS Bonus
           FROM Databas.Tabl
           WHERE TimeLogged='Noon'
           GROUP BY NULL) Results
     ON 0 = Results.Bonus
WHERE Status='URGENT';

This does use sub-SELECTs, which I was initially hoping to avoid, but now realize that hope may have been foolish. Plus it seems like the COUNTing SELECT sub-queries will be less costly than the main query since the COUNT conditionals are all on one table, but the real SELECT I’m working with has to join on multiple different tables for derived information.

The key realizations are that I can GROUP BY NULL, which will return a single result so that COUNT(*) will actually catch everything, and that I can force a correlation to this column by just faking a Bonus column with 0 on both tables.

It looks like this is the solution I will be using, but I can’t actually accept it as an answer until tomorrow. Thanks for all the help.

  • 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-17T02:00:20+00:00Added an answer on May 17, 2026 at 2:00 am
    SELECT Tabl.Name, Tabl.Address, Results.Totals
    FROM Databas.Tabl
    LEFT JOIN (SELECT COUNT(*) AS Totals, 0 AS Bonus
               FROM Databas.Tabl
               WHERE TimeLogged='Noon'
               GROUP BY NULL) Results
         ON 0 = Results.Bonus
    WHERE Status='URGENT';
    

    I figured this out thanks to ideas generated by multiple answers, although it’s not actually the direct result of any one. Why this does what I need has been explained in the edit of the original post, but I wanted to be able to resolve the question with the proper answer in case anyone else wants to perform this silly kind of operation. Thanks to all who helped.

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

Sidebar

Related Questions

I have a simple jasper report that does not need a datasource so I
I have a simple jasper report which shows some data from database. The jasper
I have a grid view that has two simple columns, a report number and
i have a very simple report that is generated from just one table. one
So I have a simple crosstab report that calculates number of sales in the
I have a simple report that I want to export to a CSV file.
We have are relatively simple Reporting Services report that our users commonly export to
I have a simple customers table designed this way (I report only some fields,
I have a simple form, a query and a report in Access 2003. I
I have a simple report made with FetchXml that shows something like this: EMPLOYEE

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.