这是我的选择声明:
SELECT DISTINCT
ms.createdon
,c.new_memberid
,c.firstname
,c.lastname
,c.new_primaryclubname
,a.line1
,a.city
,a.stateorprovince
,a.postalcode
,c.telephone1
,c.telephone2
,c.birthdate
,c.gendercodename
,p.ProductNumber
,mr.new_backgroundcheckflagname
,c.emailaddress1
,c.new_divisioncode
,c.emailaddress2
FROM
Filterednew_membershiprequirement AS mr
LEFT JOIN Filteredcontact AS c ON mr.new_contact = c.contactid
LEFT JOIN FilteredCustomerAddress AS a ON c.contactid = a.parentid
INNER JOIN Filterednew_membership AS ms ON c.contactid = ms.new_contact
INNER JOIN Product AS p ON ms.new_product = p.ProductId
WHERE
c.new_divisioncode = 'I' AND c.new_memberid= '123465789'
我在Filterednew_membership
上有一个列引起了我的问题,因为它有一个自动编号,这意味着每次使用它时,它都会有一个唯一的标识符,即使每个其他数据字段都相同。如何告诉SQL忽略此列,以便将其他字段仅作为一行而不是多行?
所以我得到了:
CreatedOn | MemberId | Full Name | ProductNum | EVILUNIQUEID
-------------------------------------------------------
01/01/01 | 12345678 | Bobb Ross | 10000 | 1
01/01/01 | 12345678 | Bobb Ross | 10000 | 2
01/01/01 | 12345678 | Bobb Ross | 10000 | 3
01/01/01 | 12345678 | Bobb Ross | 10001 | 4
我想要的是:
CreatedOn | MemberId | Full Name | ProductNum
---------------------------------------------
01/01/01 | 12345678 | Bobb Ross | 10000
01/01/01 | 12345678 | Bobb Ross | 10001
答案 0 :(得分:1)
只需从select子句中删除列名。