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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:08:16+00:00 2026-05-15T17:08:16+00:00

When I run query number 1: SELECT id, name, COUNT(name) AS count FROM markers

  • 0

When I run query number 1:

SELECT id, name, COUNT(name) AS count 
  FROM markers 
 WHERE state like 'OR' 
group by named

I get the following results:

id  name                count
14  Alsea               2
76  Applegate Valley    1
3   Ashland             9
64  Beaver              1
26  Bend                1
10  Carlton             2

This is fine, except, I want each instance of a counted name to appear with its respective ID as seen in the result of query number 2:

SELECT id, name, COUNT(name) AS count 
  FROM markers 
WHERE state like 'OR' 
group by name, id

Which produces the following results:

id  name                count
14  Alsea               1
28  Alsea               1
76  Applegate Valley    1
3   Ashland             1
13  Ashland             1
16  Ashland             1
20  Ashland             1
22  Ashland             1
43  Ashland             1
48  Ashland             1
51  Ashland             1
72  Ashland             1
64  Beaver              1
26  Bend                1
10  Carlton             1
27  Carlton             1

Is there a query I can run that will return the id and name from query number 2 and the corresponding count from query number 1 in each row as shown below?

id  name                count
14  Alsea               2
28  Alsea               2
76  Applegate Valley    1
3   Ashland             9
13  Ashland             9
16  Ashland             9
20  Ashland             9
22  Ashland             9
43  Ashland             9
48  Ashland             9
51  Ashland             9
72  Ashland             9
64  Beaver              1
26  Bend                1
10  Carlton             2
27  Carlton             2
  • 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-15T17:08:16+00:00Added an answer on May 15, 2026 at 5:08 pm

    Try this:

    SELECT id, name, 
     (SELECT COUNT(name) 
       FROM markers im 
       WHERE state like 'OR' 
       GROUP BY name 
       HAVING im.name=m.name) as count
    FROM markers m 
    WHERE state like 'OR' 
    GROUP BY name, id 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I run the query : select count(*) from (select idCover from x90..dimCover group
If I run a query such as: SELECT COUNT(*) as num FROM table WHERE
I'm attempting to run this Oracle query... SELECT COUNT(*) as total, q1 FROM exit_responses
I am trying to run the following query to insert a number of nodes
If I run this query in Toad: SELECT BANDID, BANDNAME FROM WOODSTOCK WHERE BANDNAME
If I run a query simialr to: SELECT * FROM user u LEFT JOIN
I have a query which is crossing two tables select count(*) from ingenium.empevt, ingenium.evt
I have a saved query in MS Access 2007 named test. SELECT Count(system_info.id) AS
I have the following query: SELECT l.id, (SELECT amount FROM lead_status WHERE lead_id =
When I run the query: select (100/50) It give me 2 - good. But

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.