Solved

How to format group by sql statement?

Posted on 2007-11-15
2
790 Views
Last Modified: 2010-04-21
I would like the following output where each name is listed only once using sql 2000:

Name       count
name       4
name 2    1

I am getting:
Name       count
name       4
name       3
name 2    1
 
sql code I am using:
select co.name, count(n.attitude)  as Total
from customer c, coment n, subcompany co
group by co.name, c.indx, n.indx, n.attitude
having c.indx = n.indx and  c.company = co.code and n.indx = c.company

0
Comment
Question by:swansonplace
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 20290784
select co.name, count(n.attitude)  as Total
from customer c
join coment n
  on c.indx = n.indx
 and n.indx = c.company
join subcompany co
  on c.company = co.code
group by co.name

0
 

Author Closing Comment

by:swansonplace
ID: 31409372
Thank you.  That was clean and it worked.
0

Featured Post

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question