Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8899501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:52:20+00:00 2026-06-15T00:52:20+00:00

I am facing problem in query result in which if i use order by

  • 0

I am facing problem in query result in which if i use order by on resultset returned after group by , the grouping order is disturbed .

select a.location_id,a.feed_date 
  from p_article_table
  inner join m_misc_details l on a.location_id = l.misc_detail_id 
   and misc_master_id=2 
   and a.location_id in (1,2,4,5,6,7,8)
   and  convert(varchar(11),a.feed_date,108)<'09:01:00'
group by a.location_id,a.feed_date 
order by a.feed_date

What should I do ?

The result after GROUP BY on location_id gives

1   
1
1
1
5
7
7
7
8

But after I use ORDER BY on feed_date , the result gets disturbed

1
1
5
7
1
8
1
..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:52:21+00:00Added an answer on June 15, 2026 at 12:52 am

    The grouping operation is not affected by order by. The order that the grouped records are returned withoout an order by is arbitrary.

    Did you want this:

    select a.location_id,a.feed_date 
      from p_article_table
      inner join m_misc_details l on a.location_id = l.misc_detail_id 
       and misc_master_id=2 
       and a.location_id in (1,2,4,5,6,7,8)
       and  convert(varchar(11),a.feed_date,108)<'09:01:00'
    group by a.location_id, a.feed_date 
    order by a.location_id, a.feed_date
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I facing some problem in SQL query.I try to use select result in other
I am facing a problem displaying the result of my select * query on
I m facing a problem to write a SQL query to get result in
I am facing problem to get variable from query string. I have used htaccess
I am facing problem with the control flajaxian.FileUploader i.e. after downloading the dll file
I'm facing a strange problem right now... I'm trying to use Facebook API to
I'm facing a kind of strange problem and don't know in which direction to
I am facing problem with an Oracle Query in a .net 2.0 based windows
Yii beginner here. I am facing some problem with how to query the database
i'm facing a design problem within my project. PROBLEM i need to query solr

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.