Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting multiple columns in different orders ASC & DESC not working

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I am filling a Gridview in ASP 4 vb.
I have a counter in the first column to help users know counts as they choose different options from drop downs. The sort is created when a user clicks on a column heading in the Gridview.
So when they sort the column in Descending order the other rows don’t match up all the way.
It like it gets confused and part way down the order is out of whack.
Only the first column wants to be sorted Descending since I want Vendors, managers and names afterwords sorted alphabetically. this is what seems to get out of sync. the first column appears to sort correctly, it's the others that do not.
Any ideas?
Code:
Select ROW_NUMBER() OVER (ORDER BY WAG.WeekEndDate ASC, WAG.Vendor ASC, WAG.Manager ASC, WAG.ResourceLastName ASC, WAG.ResourceFirstName ASC) AS Counter, WAGM.Vendor,WAGM.ResourceLastName, WAGM.ResourceFirstName, WAGM.Manager, WAG.TotalHours, Convert(nvarchar(12),WAG.ApprovedDate,101) AS ApprovedDate, Convert(nvarchar(12),WAG.WeekEndDate,101) AS WeekEndDate, 'Timesheet' = Case When WAG.ResourceFirstName IS NULL Then 'NOT IN' Else 'IN' End , convert(nvarchar(12),WAG.TimeSheetSubmittedDate,101) as DateSubmitted From WeekAtAGlanceMissing WAGM left join WeekAtAGlance WAG ON WAGM.ResourceLastName = WAG.ResourceLastName And WAGM.ResourceFirstName = WAG.ResourceFirstName Inner Join SOWResources SOWR on WAGM.ResourceLastName = SOWR.ResourceLastName AND WAGM.ResourceFirstName = SOWR.ResourceFirstName Where SOWR.EndDate = '2100-12-31' And WAGM.Vendor is not null order by WAG.WeekEndDate ASC, WAG.Vendor ASC, WAG.Manager ASC, WAG.ResourceLastName ASC, 
WAG.ResourceFirstName ASC;

DougP
 
Could you post some simple data and desired result?

Borislav Borissov
VFP9 SP2, SQL Server
 
DougP, your row number function is done in SQL, and will generate based on what you have provided.
When you sort in a grid view you are bypassing the sort specified in the query, and by default, you can only sort on one column at a time.

Lodlaiden

You've got questions and source code. We want both!
Here at tek tips, we provide a hand up, not a hand out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top