您可以根据需要建议如何显示下面的数据。按照需求显示表格数据的SQL查询
表(XX)数据:
id type amount
--- ---- -----
1 A 23.0
2 A 12.0
3 A 34.0
4 B 17.0
5 B 16.0
6 B 20.0
要求:我想显示输出如下
type A amount type B amount
------------- -------------
23.0 17.0
12.0 16.0
34.0 20.0
我曾尝试下面的查询,但它被取重复的行
select a.amount,b.amount
from xx,(select * from xx where type='A')a,(select * from xx where type='B')b
where xx.id=a.id and xx.id=b.id
你怎么知道'23.0'属于像'17.0'一样的输出行?对我来说,看起来你正在创建没有明显连接的对。 –