order by with group by | Bytes (2024)

Home Posts Topics Members FAQ

Ike

If I have a GROUP BY statement, which groups my multiple fields, e.g.:

SELECT ......GROUP BY date, store

can I have multiple ORDER BY statements with that? e.g.:

SELECT ......GROUP BY date, store ORDER BY date asc, store, desc

Is this an acceptable syntax? Thanks, Ike

May 7 '06 #1

Subscribe Reply

1 order by with group by | Bytes (1) 1812 order by with group by | Bytes (2)

Bill Karwin

Ike wrote:

SELECT ......GROUP BY date, store ORDER BY date asc, store, desc

Is this an acceptable syntax? Thanks, Ike

Yes, that's the idea, except your statement has an extra comma. You
should use the following:

ORDER BY date asc, store desc

Regards,
Bill K.

May 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1 13571

Order By Performance Problem on View

by: Scott |last post by:

I have a view that contains the following SQL1 and it takes about 500ms to run with Explain Plan EXP1. However, if I add an order by clause(e.g. select * from view1 order by ID desc), it will then take about 3 mins to return. The explain plan for the query with the order by clause is as follows (EXP2). The explain plan 2 shows that there is...

Oracle Database

2 5421

GROUP BY and ORDER BY

by: Experienced but Undocumented |last post by:

Here's another one; thanks so much to everyone who helped with my last problem. I can't upgrade mySQL but I figured out a way around it from your examples. SELECT `subject` , max( `datetime` ) FROM `table` WHERE 1 GROUP BY `subject` ORDER BY `datetime` DESC LIMIT 0 , 30

MySQL Database

1 1760

Interesting Problem with Child element order

by: jrmsmo |last post by:

Hi there, I have an interesting problem that maybe you pros can suggest how I solve. I'm working with a third party program that serializes an XML document (it was obviously not designed with schema in mind). I created a schema from this document. It works fine. Except for some unknown reason, in a small part of the XML document, this program...

.NET Framework

2 3111

Report showing products in descening order

by: Hohn Upshew |last post by:

I need some help to build a report enumerating the products in descending order depending on the sum of liters. In this way i can view the top products sold for a given period.But i fail to do it. In my query i have build a total as follows SELECT products.Productid, products.grade, products.size, Sum(.liters) AS SumOfliters,...

Microsoft Access / VBA

2 7760

General sort order

by: adrian.chandler |last post by:

Hi all, I have been using letter and symbol codes such as GNU< GNU\ GNU} GNUˆ in an Access table. I was surprised to see that when the table was sorted on this field, the order is: GNUˆ GNU_ GNU} GNU< I was expecting:

Microsoft Access / VBA

104 10803

ORDER BY in VIEW not working

by: Beowulf |last post by:

I have the view below and if I use vwRouteReference as the rowsource for a combo box in an MS Access form or run "SELECT * FROM vwRouteReference" in SQL Query Analyzer, the rows don't come through sorted by Numb. Everything I've read on the web suggests that including the TOP directive should enable ORDERY BY in views. Does someone have an...

Microsoft SQL Server

3 3977

by: Hartmut Dippon |last post by:

Hi all, I hope somebody can help me with following problem: I have an application where I can drag&drop files/dirs from within explorer onto my form. If multiple files/dirs are selected I can see that the order I get in my drop event is not always the same as displayed in the explorer window. Further more the order changes depending on...

C# / C Sharp

15 1947

Question about evaluation order

by: Jeroen |last post by:

Hi all, I've got a very specific question about the evaluation order in C++. Assume some kind of custom array class, with an overloaded subscript operator. In the following code: { my_array a, b, c; a = b + c;

C / C++

2 1327

ORDER BY error, need help!!

by: speavey |last post by:

When I run this query, I get an ORDER BY error "Incorrect syntax near the keyword 'ORDER'. I've bolded it below. If I take the ORDER by out then it works correctly, but I need the ORDER BY because of the TOP 9. Any Suggestions??? (SELECT TOP 9 trans.vchTrustee, trans.vchCaseNumber, Trans.TotalReceipts + SUM(a.mnyBalanceAmount) As Top9Total...

Microsoft SQL Server

3 3858

group by works, order by gives error msg

by: ylekot88 |last post by:

Hi I am a student, I am trying to figure this out. I am trying to run a select statement that is asking for customer#, date, and total price of each order. ensure results are in chronological order based upon order date. When I run the following with just a group by clause, it works. If I add order by orderdate, I get an error message that...

Oracle Database

7547

Changing the language in Windows 10

by: Hystou |last post by:

Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...

Windows Server

7825

Problem With Comparison Operator <=> in G++

by: Oralloy |last post by:

Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...

C / C++

1 7588

The easy way to turn off automatic updates for Windows 10/11

by: Hystou |last post by:

Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...

Windows Server

7904

Discussion: How does Zigbee compare with other wireless protocols in smart home applications?

by: tracyyun |last post by:

Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...

General

6176

AI Job Threat for Devs

by: agi2029 |last post by:

Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...

Career Advice

5171

Couldn’t get equations in html when convert word .docx file to html file in C#.

by: conductexam |last post by:

I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...

C# / C Sharp

3575

Windows Forms - .Net 8.0

by: adsilva |last post by:

A Windows Forms form does not have the event Unload, like VB6. What one acts like?

Visual Basic .NET

1 1159

How to add payments to a PHP MySQL app.

by: muto222 |last post by:

How can i add a mobile payment intergratation into php mysql website.

PHP

865

Comprehensive Guide to Website Development in Toronto: Expert Insights from BSMN Consultancy

by: bsmnconsultancy |last post by:

In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

General

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisem*nts and analytics tracking please visit the page.

order by with group by | Bytes (2024)
Top Articles
Latest Posts
Article information

Author: Sen. Emmett Berge

Last Updated:

Views: 6062

Rating: 5 / 5 (80 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Sen. Emmett Berge

Birthday: 1993-06-17

Address: 787 Elvis Divide, Port Brice, OH 24507-6802

Phone: +9779049645255

Job: Senior Healthcare Specialist

Hobby: Cycling, Model building, Kitesurfing, Origami, Lapidary, Dance, Basketball

Introduction: My name is Sen. Emmett Berge, I am a funny, vast, charming, courageous, enthusiastic, jolly, famous person who loves writing and wants to share my knowledge and understanding with you.