can anybody help? there's a table containing data about games...including:
name VARCHAR(255)
platform VARCHAR(255)
year_of_release YEAR
genre VARCHAR(255)
publisher VARCHAR(255)
na_sales DOUBLE(10,2)
other_sales DOUBLE(10,2)
global_sales DOUBLE(10,2)
when i run this query:
select Name, Year_of_Release, Other_Sales, Global_Sales from (
select *
from games
where Year_of_Release >=2000
order by Global_Sales desc, Name asc
) a
union all
select Name, Year_of_Release, Other_Sales, Global_Sales from (
select *
from games
where Year_of_Release < 2000
order by Other_Sales desc, Name asc
) b
;
i want the rows with year_of_release >=2000 appear first and after that rows with year_of_release<2000 appear.for the first group i want to sort by Global_sale and for second one by Other_sale...and if two rows was equal sale, sort by name in asc form.
Thanks for help.
i tried almost everything on the web,didn't work.
select col1, col2 from games where.... union all select col1, col2 from games where... order by name asc