Solved

How to format group by sql statement?

Posted on 2007-11-15
2
782 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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

Suggested Solutions

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…

737 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