codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Ordering of 2 columns ACS, DESC at the same time  hulan at 12:53 on Monday, June 07, 2004
 

Hi there,

Does anyone know if i could 2 columns 1 by ascending and the other one by descending. I have 2 tables, both related by sport code:

[code]
Table: sports_played

parent_id child_id sport_code level
1 1 SW Advanced
1 1 SR Advanced
2 1 TN Intermediate
2 2 TN Beginner
2 2 HK Advanced
3 1 SR Intermediate
3 1 RG Intermediate
3 1 BS Beginner
5 1 BS Advanced


Table: sport
sport_code, sport_name, winter summer_sport
SW Swimming Yes Yes
TN Tennis Yes Yes
RG Rugby Yes No
BS Basketball No Yes
HK Hockey No Yes
SR Soccer Yes No
SL Sailing No Yes

[/code]
And what I need to have is a table that lists how many children play each summer sport at each of the levels (Beginner, Intermediate, and Advanced).

And the ordering has to be done listed in descending order of the sport_name , then in ascending order of number of children who play the sport at the level.

My SQL statements are:

[code]
SELECT sport.sport_name, Count(sports_played.level) As SumOfLevels
FROM sports_played RIGHT OUTER JOIN sport
ON sports_played.sport_code =
sport.sport_code
AND sport.summer_sport = ‘Yes’
ORDER BY sport.sport_name DESC;




SELECT sport.sport_name, Count(sports_played.level) AS SumOfLevels
FROM sports_played LEFT OUTER JOIN sport
ON sports_played.sport_code = sport.sport_code
AND sport.summer_sport = ‘Yes’
ORDER BY sports_played.level ASC;
[/code]

The reason I have 2 tables is (i thought) i can't have both sport_name Desc and sports_played ASC order. since the order will both collide with each other, and will give me an error.

Another question is can I use Count() to differentiate each 3 level, even though they are strings? Is it possible?

regards,
hulan









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  How to dynamically create a calendar when I click a button?
•  c++ tutorials
•  Update a second table
•  Trackin Site behaviour
•  variable scope problem
•  dynamic crystal report generation
•  execute an Excel macro when the sheet is changed from ASP.NET
•  Re: form
•  form


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005