本文介绍了一列中几个不同字段的行数不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以帮忙吗?我在下面有一个现有查询(SQL Server),它正在运行并提取数千行.但是,我需要为vw_client_uli_member_type"表中的一列中的几个不同字段值选择特定数量的行.我在哪里以及如何处理这种情况?谢谢.
Can someone help? I have an existing query below(SQL Server) that is running and pulls thousands of rows.However, I need to select a specific number of rows for a few different field values in one of the column in 'vw_client_uli_member_type' table. Where and how do I pit this condition? Thank you.
select ind_int_code as 'Individual Type',
ind_first_name as 'First Name',
ind_last_name as 'Last Name',
cst_recno as 'Member ID',
cst_eml_address_dn as 'Email Address',
adr_city as 'City',
adr_state as 'State' ,
adr_country as 'Country',
cst_org_name_dn as 'Company',
cst_ixo_title_dn as 'Job Title',
mem_member_type as 'Member Type'
FROM
co_individual WITH (NOLOCK)
JOIN co_individual_ext WITH (NOLOCK) ON ind_cst_key_ext=ind_cst_key
JOIN co_customer WITH (NOLOCK) ON cst_key=ind_cst_key and ind_delete_flag=0
and ind_deceased_flag=0
LEFT JOIN co_customer_x_address WITH (NOLOCK) ON cst_cxa_key=cxa_key
LEFT JOIN co_address WITH (NOLOCK) ON adr_key=cxa_adr_key
LEFT JOIN vw_client_uli_member_type WITH (NOLOCK) ON cst_key=mem_cst_key
WHERE mem_member_type Is Not Null AND mem_expire_date >= '8/22/2017' AND adr_country = N'UNITED STATES' AND ind_deceased_flag != 1 AND ind_key_leader_flag_ext != 1 AND ind_int_code != N'Staff' AND ind_int_code != N'Spouse' AND ind_int_code != N'Press'
推荐答案
如果需要限制行数,在查询末尾添加即可:
If you need to limit the number of rows, just add at the end of the query:
LIMIT number_rows
如果您使用的是 MySQL,或者
if you're using MySQL, or
SELECT TOP number_rows
如果您使用的是 SQL Server.
if you're using SQL Server.
在此处查看更多信息.
这篇关于一列中几个不同字段的行数不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!