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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:33:49+00:00 2026-05-28T07:33:49+00:00

I have a Column(Fields) that contain multiple values for each entity (One to Many).

  • 0

I have a Column(Fields) that contain multiple values for each entity (One to Many).

Example: A record can can reference multiple values in this column.

What I want to do is get only records where highest(MAX) value in this column is equals zero.

The first thing I did was convert the values in the column to Integer, this way I can get the Max Value.

Here is my Code:

How do I get the Max code? If a record has more than one code. I want only record with the Max or highest code of 00000.

I am getting an error with the Having clause since I cannot use Aggregate in the Where Clause.

SELECT CUSTOMER.USER_ID, MAX(CInt(CUSTOMER.REC_CODE)) AS ACTIVE_REC_CODE, 
CUSTOMER.CUS_TYPE


FROM CUSTOMER


WHERE ((CUSTOMER.REC_CODE) IS NOT NULL )


GROUP BY

CUSTOMER.USER_ID, CUSTOMER.REC_CODE, CUSTOMER.CUS_TYPE


HAVING  MAX(CInt([CUSTOMER.REC_CODE])= 00000 )
  • 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-28T07:33:50+00:00Added an answer on May 28, 2026 at 7:33 am

    You are close, but you need to remove CUSTOMER.REC_CODE from your WHERE, since you want the max value of that column. This should work:

    SELECT CUSTOMER.USER_ID, MAX(CInt(CUSTOMER.REC_CODE)) AS ACTIVE_REC_CODE, CUSTOMER.CUS_TYPE
    FROM CUSTOMER
    WHERE CUSTOMER.REC_CODE IS NOT NULL 
    GROUP BY CUSTOMER.USER_ID, CUSTOMER.CUS_TYPE
    HAVING  MAX(CInt([CUSTOMER.REC_CODE])) = 0 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VARCHAR column in a SQL Server 2000 database that can contain
I have a column that has fields such as C5, C6, C3, CC, CA,
I have column with varchar values like 022008 that I need to convert into
Is there a way to search for fields that contain similar values in a
I have a very simple query that only returns one record. When I try
I have a table that contains multiple rows. Each row contains 5 columns (or
I have a file that can contain from 3 to 4 columns of numerical
I have a list of fields/columns that comprises of Sharepoint specific fields/columns, my own
I have column that contains strings. The strings in that column look like this:
I have column named summary (tinytext, utf8_turkish_ci). I know it can store 255 byte

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.