Solved

How to format group by sql statement?

Posted on 2007-11-15
2
726 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
2 Comments
 
LVL 142

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now