Home » SQL & PL/SQL » SQL & PL/SQL » sort with duplicate records (12)
sort with duplicate records [message #684037] Sat, 27 March 2021 15:51 Go to next message
mape
Messages: 280
Registered: July 2006
Location: Slovakia
Senior Member
Hello

I would like to know how sort records with duplicate dates ?
And I need to sort by date and balance decrease.

For instance:

   date                 balance
02.02.2021 23:12:56    708  
02.02.2021 23:12:56    708
02.02.2021 23:12:56    232
02.02.2021 23:30:50    345    


Its doesnt work fine with select:
select * from table
group by date,balance
Thanks


Re: sort with duplicate records [message #684038 is a reply to message #684037] Sat, 27 March 2021 16:17 Go to previous messageGo to next message
Michel Cadot
Messages: 67887
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

What about a feedback in your topic?
What about your Oracle version as asked in the forum rules?
What about a test case as asked so many times in your topics?

Re: sort with duplicate records [message #684040 is a reply to message #684037] Sun, 28 March 2021 01:47 Go to previous messageGo to next message
John Watson
Messages: 8560
Registered: January 2010
Location: Global Village
Senior Member
Are you confusing ORDER BY with GROUP BY?

(and btw, I wish you would not say "record" when you mean "row").
Re: sort with duplicate records [message #684041 is a reply to message #684040] Sun, 28 March 2021 02:35 Go to previous messageGo to next message
mape
Messages: 280
Registered: July 2006
Location: Slovakia
Senior Member
I mean order by, not group by of course, syntax error.

Its necessery to use analytic function, I need to figure it out.

The result shoud be order by DATE, and when DATE is duplicated sort by balance yet.

[Updated on: Sun, 28 March 2021 02:40]

Report message to a moderator

Re: sort with duplicate records [message #684042 is a reply to message #684037] Sun, 28 March 2021 06:10 Go to previous messageGo to next message
Solomon Yakobson
Messages: 3063
Registered: January 2010
Location: Connecticut, USA
Senior Member
mape wrote on Sat, 27 March 2021 16:51
I need to sort by date and balance decrease.
select * from table
order by date,balance desc
SY.
Re: sort with duplicate records [message #684043 is a reply to message #684042] Sun, 28 March 2021 12:01 Go to previous message
mape
Messages: 280
Registered: July 2006
Location: Slovakia
Senior Member
Yes, this simple order works fine Smile
thanks
Previous Topic: 12.1.0.1
Next Topic: Analytical functions
Goto Forum:
  


Current Time: Mon Jun 21 23:35:12 CDT 2021