SELECT title_id,title,amt
FROM (
SELECT title_id,title,advance AS amt, 0 AS sorted
FROM titles
UNION ALL
SELECT title_id,title,price AS amt, 1 AS sorted
FROM titles) a
GROUP BY title_id,title,amt
ORDER BY MIN(sorted)
FROM (
SELECT title_id,title,advance AS amt, 0 AS sorted
FROM titles
UNION ALL
SELECT title_id,title,price AS amt, 1 AS sorted
FROM titles) a
GROUP BY title_id,title,amt
ORDER BY MIN(sorted)
(select title_id,title,amt=advance
from titles tt
union
select title_id,title,amt=price
from titles dtl
)a
order by a.title
未解决前的结果:
PC1035 But Is It User Friendly? 22.9500
PC1035 But Is It User Friendly? 7000.0000
PS1372 Computer Phobic AND Non-Phobic Individuals: Behavior Variations 21.5900
PS1372 Computer Phobic AND Non-Phobic Individuals: Behavior Variations 7000.0000想要的结果:
PC1035 But Is It User Friendly? 7000.0000
PC1035 But Is It User Friendly? 22.9500
PS1372 Computer Phobic 7000.0000
PS1372 Computer Phobic 21.5900请大侠们帮忙!!!!