Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Order by Date column Expand / Collapse
Author
Message
Posted Wednesday, November 14, 2012 3:55 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 10:12 PM
Points: 67, Visits: 255
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
Posted Wednesday, November 14, 2012 4:43 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 1:05 PM
Points: 3,984, Visits: 5,237
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
Posted Wednesday, November 14, 2012 4:50 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 10:12 PM
Points: 67, Visits: 255
No still doesnt work, its happening based on seq_no only.

PFA


  Post Attachments 
abc1.png (13 views, 60.24 KB)
Post #1384540
Posted Wednesday, November 14, 2012 6:40 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 1:05 PM
Points: 3,984, Visits: 5,237
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
Posted Wednesday, November 14, 2012 7:17 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 5:14 PM
Points: 35,266, Visits: 31,756
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 "Row-By-Agonizing-Row".

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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1384613
Posted Wednesday, November 14, 2012 7:18 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 5:02 PM
Points: 20,705, Visits: 32,354
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
Posted Thursday, November 15, 2012 10:35 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Sunday, September 29, 2013 1:24 AM
Points: 429, Visits: 1,721
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 »

Add to briefcase

Permissions Expand / Collapse