添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
group by 前面相同的字段,后面不同的,用max取。
SELECT m.member_id,
prefix_desc 'Prefix:',
UPPER(first_name) 'First Name:',
UPPER(last_name) 'Last Name:',
UPPER(email) 'Email:',
LOWER(user_id) 'User ID:',
REPLICATE('*',LEN(password)) 'Password:',
('****'+SUBSTRING(license_no,5,4)) 'Drivers Licese Number:',
REPLACE(email_ind,'Y','Accept') 'Email notification:',
REPLACE(return_ind,'Y','Accept') 'HERIZ E-RETURN',
max(CASE WHEN tel_type= 'B' THEN tel_number END + ' '+REPLACE(pref_phone_ind,'P','PREF')) 'Business Phone',
max('('+ p.country_code + ')'+ CASE WHEN tel_type= 'M' THEN tel_number END) 'Mobile Number',
max(CASE WHEN tel_type= 'F' THEN tel_number END) 'Fax'
FROM MEMBER m, license l, phone_fax p
WHERE m.member_id = l.member_id
AND m.member_id = p.member_id
AND m.member_id = 'A000001'
group by
m.member_id,
prefix_desc 'Prefix:',
UPPER(first_name) 'First Name:',
UPPER(last_name) 'Last Name:',
UPPER(email) 'Email:',
LOWER(user_id) 'User ID:',
REPLICATE('*',LEN(password)) 'Password:',
('****'+SUBSTRING(license_no,5,4)) 'Drivers Licese Number:',
REPLACE(email_ind,'Y','Accept') 'Email notification:',
REPLACE(return_ind,'Y','Accept') 'HERIZ E-RETURN'