Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 - General
»
Order by Date column
Order by Date column
Rate Topic
Display Mode
Topic Options
Author
Message
tonyarp05 61903
tonyarp05 61903
Posted Wednesday, November 14, 2012 3:55 AM
Valued Member
Group: General Forum Members
Last Login: Tuesday, June 11, 2013 12:34 AM
Points: 54,
Visits: 191
Hi,
I have query to execute the output.
It should be sorted with date also, but its sorting with only Seq_no.
PFA - for more details
please help me on this.
Post Attachments
abc.png
(
29 views,
60.30 KB
)
Post #1384522
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
Posted Wednesday, November 14, 2012 4:43 AM
Hall of Fame
Group: General Forum Members
Last Login: Thursday, June 13, 2013 9:46 AM
Points: 3,157,
Visits: 4,341
Have you tried adding the Date column to the ORDER BY clause
ORDER BY Seq, Date
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1384538
tonyarp05 61903
tonyarp05 61903
Posted Wednesday, November 14, 2012 4:50 AM
Valued Member
Group: General Forum Members
Last Login: Tuesday, June 11, 2013 12:34 AM
Points: 54,
Visits: 191
No still doesnt work, its happening based on seq_no only.
PFA
Post Attachments
abc1.png
(
13 views,
60.24 KB
)
Post #1384540
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
Posted Wednesday, November 14, 2012 6:40 AM
Hall of Fame
Group: General Forum Members
Last Login: Thursday, June 13, 2013 9:46 AM
Points: 3,157,
Visits: 4,341
Please provide an example of how you expect the output to appear.
Per the screenprint, only one of each sequence has a date, which appears with the first row of each sequence.
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1384595
Jeff Moden
Jeff Moden
Posted Wednesday, November 14, 2012 7:17 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Yesterday @ 9:01 PM
Points: 33,111,
Visits: 27,037
tonyarp05 61903 (11/14/2012)
Hi,
I have query to execute the output.
It should be sorted with date also, but its sorting with only Seq_no.
PFA - for more details
please help me on this.
I agree with what Stewart posted. You're missing some date data. Do you want that filled in? If so, what order do you wannt the dates to "smear" down in? By Seq-No???
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #1384613
Lynn Pettis
Lynn Pettis
Posted Wednesday, November 14, 2012 7:18 AM
SSC-Insane
Group: General Forum Members
Last Login: Yesterday @ 9:17 PM
Points: 21,832,
Visits: 27,855
In addition, please take the time to read and following the instructions in the first article I have referenced below in my signature block regarding asking for help.
We really need the DDL (CREATE TABLE statement) for the table(s) involved, sample data (as a series of INSERT INTO statements) for each table, the expected results based on the sample data, and most importantly your code you are using now.
Beyond that, all you are going to get based on an image is guess work, and my crystal ball hasn't worked in years.
Lynn Pettis
For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here
or
when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here
and
here
Managing Transaction Logs
SQL Musings from the Desert
Fountain Valley SQL
(My Mirror Blog)
Post #1384614
Steven Willis
Steven Willis
Posted Thursday, November 15, 2012 10:35 AM
SSC Veteran
Group: General Forum Members
Last Login: Yesterday @ 5:43 PM
Points: 298,
Visits: 1,320
tonyarp05 61903 (11/14/2012)
No still doesnt work, its happening based on seq_no only.
PFA
The output appears to be sorting exactly as specified. It's ordered first by SeqNum and then within each group of SeqNum they are ordered by Date (some of which appear to be blank or null).
Another option is to look up some articles on using the ROW_NUMBER() operator for creating nested ordering. That operator can let you do just about any grouping/sorting you want by creating "sort" columns for as many levels or groups you need. This method can be a bit complex, but if you give us some data examples and the desired output then perhaps one of us can give you specific examples to get your desired result.
Post #1385270
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.