English 中文(简体)
利用SQ服务器和冷聚物重新定义彩礼
原标题:Refining Query result using SQL Server and Coldfusion

我有一个问题,即提供像数据这样的数据。

ID  Value   AttributeID     IDParent
286 Fleet   9               284         
286 239     10              284         
286 1       12              284         
208 Rivers  9               -1          
208 319     10              -1          
208 0       12              -1  

这一结果需要改进。 使用“问问问问问问问问问问问问问问问答”的方法是否可改变。

ID  Value   PageID     Show IDParent
286 Fleet   239         1    284
208 Rivers  319         0   -1          

或者说,这样做会更好。

最佳回答

你可以这样做:

select t.ID,
       t.Value,
       aux1.Value as  PageID 
       aux2.Value as  Show 
       t.IDParent
from tablename t
inner join tablename aux1 on aux1.IDParent = t.IDParent and aux1.AttributeID = 10
inner join tablename aux2 on aux2.IDParent = t.IDParent and aux2.AttributeID = 12
where t.AttributeID = 9
问题回答

暂无回答




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签