Solved

MySQL  need to add GROUP BY State  to existing query

Posted on 2014-03-11
4
456 Views
Last Modified: 2014-03-11
The following query works well except when i try to add GROUP BY

    SELECT *
      FROM        tblEvents AS EVT
      WHERE        EVT.Online='1'  AND  (etc)    
      ORDER BY EVT.Date ASC, EVT.Time
        GROUP BY State

How to re format so i can aggregate for States together (groupings ordered alphabetically by State), then within each State, ordered by date

thank you!
0
Comment
Question by:willsherwood
[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
  • 3
4 Comments
 
LVL 17

Accepted Solution

by:
Kent Dyer earned 500 total points
ID: 39922486
Do you have to do a SELECT *

??

It is considered poor practice to use SELECT * in your queries..  Yes, even if you have 140 columns in your table..

Group BY should be only necessary for when you use a COUNT in SQL....  Yes, you can order the result set, but when you use GROUP BY, you are going to have list out the columns to group..

HTH
0
 

Author Comment

by:willsherwood
ID: 39922504
hmmm  . . .  so there's no sub-select solution to pre-sort them by State clusters?
(sounds like i mis-used the keyword GROUP, sorry)

there are probably 23 fields out of 25 that are needed in the results (it's a very details event listing spec!)
0
 

Author Comment

by:willsherwood
ID: 39922507
so then just several levels of ORDER BY?
State ASC, Date ASC, Time ASC
0
 

Author Closing Comment

by:willsherwood
ID: 39922524
thank you!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
compare date to getdate() 8 34
MySQL programmer starter 25 64
I am new to using JSON in SQL Server 2 57
SQL join ...want to return one row 4 12
Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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