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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:25:01+00:00 2026-06-08T07:25:01+00:00

I have two table in my data base As below: CUSTOMER ( ID integer

  • 0

I have two table in my data base As below:

CUSTOMER (
  ID integer Generated Always As Identity,
  FIRSTNAME varchar(32) not null,
  LASTNAME varchar(32) not null,
  PHONENUMBER varchar(11) not null,
  ADDRESS varchar(225),
primary key (id)
);

and

APP.ORDERS (
  ID integer not null default AUTOINCREMENT: start 1 increment 1,
  CUSTOMER_ID integer References Customer(ID) ,
  EMPLOYEEID integer References Employee(ID),
  DATEOFDELIVERY date,
  primary key (id),
); 

When I try To join This two table as below every thing is fine:

 SELECT CUSTOMER_ID,firstname,LASTNAME,Address,phoneNumber From APP.Customer 
 INNER JOIN APP.Orders ON customer.ID = customer_ID 
 WHERE ORDERS.dateOfDelivery Between '2012-09-01' AND '2012-11-11'

but When I use Aggregate Function as below it give me Error:

SELECT Count(CUSTOMER_ID),firstname,LASTNAME,Address,phoneNumber 
From APP.Customer                         
INNER JOIN APP.Orders ON customer.ID = customer_ID 
WHERE ORDERS.dateOfDelivery Between '2012-09-01' AND '2012-11-11' ;

Error:

[2012-07-20 08:07:04] [42Y35][30000] Column reference 'FIRSTNAME' is invalid. When the SELECT list contains at least one aggregate then all entries must be valid aggregate expressions.  

I try to change the last code above to Orders.Count(CUSTOMR_ID) to tell the database the correct table but it give me error that there is no schema with name Orders so I change it to APP.Orders.Count(CUSTOMER_ID) but it never solve the problem.
Error :Schema 'ORDERS' does not exist

UPDATING QUESTION:

I Figur out that very simple Query Like :

SELECT COUNT(*),ID FROM Orders

will caused to This Error :

[2012-07-20 09:01:50] [42Y35][30000] Column reference 'ID' is invalid. When the SELECT list contains at least one aggregate then all entries must be valid aggregate expressions. 

So It means that it is not possible to have both aggregate function and simple column names together but I am wonder how to supply the expected out put with any equivalent Query?Any Idea?

  • 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-08T07:25:04+00:00Added an answer on June 8, 2026 at 7:25 am

    GROUP BY is the correct approach. You need to group by all the non-aggregate columns, as in:

    SELECT Count(CUSTOMER_ID),firstname,LASTNAME,Address,phoneNumber 
    From APP.Customer                         
    INNER JOIN APP.Orders ON customer.ID = customer_ID 
    WHERE ORDERS.dateOfDelivery Between '2012-09-01' AND '2012-11-11' 
    group by firstname,lastname,address,phonenumber;
    

    Think about it this way: you want to gather together all the orders for a particular customer (that’s what GROUP BY does), then you want to count up all those orders (that’s what the COUNT() function does).

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

Sidebar

Related Questions

I have a database with the following table structures... The Customer table has two
I have 10 tables in my database(MySQL). two of them is given below tbl_state
Say I have a database called Poll and have these two table structures. poll
I have two columns(column1, column2) in my oracle database table named as demo .
Lets say we have a database table with two columns, entry_time and value. entry_time
I have a database framework where I have two tables. The first table has
I have two tables in my database: user and media_contact . The media_contact table
In a MySQL database I have two tables linked in a join. One table
I have one database table TABLE_TIPS with two value 1. tips_id (auto increment) 2.
I have a very simple database table that joins two other tables in a

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.