sql server - different number of rows for a few different fields in one column -
can help? have existing query below(sql server) running , pulls thousands of rows.however, need select specific number of rows few different field values in 1 of column in 'vw_client_uli_member_type' table. , how pit condition? thank you.
select ind_int_code 'individual type', ind_first_name 'first name', ind_last_name 'last name', cst_recno 'member id', cst_eml_address_dn 'email address', adr_city 'city', adr_state 'state' , adr_country 'country', cst_org_name_dn 'company', cst_ixo_title_dn 'job title', mem_member_type 'member type' co_individual (nolock) join co_individual_ext (nolock) on ind_cst_key_ext=ind_cst_key join co_customer (nolock) on cst_key=ind_cst_key , ind_delete_flag=0 , ind_deceased_flag=0 left join co_customer_x_address (nolock) on cst_cxa_key=cxa_key left join co_address (nolock) on adr_key=cxa_adr_key left join vw_client_uli_member_type (nolock) on cst_key=mem_cst_key mem_member_type not null , mem_expire_date >= '8/22/2017' , adr_country = n'united states' , ind_deceased_flag != 1 , ind_key_leader_flag_ext != 1 , ind_int_code != n'staff' , ind_int_code != n'spouse' , ind_int_code != n'press'
if need limit number of rows, add @ end of query:
limit number_rows
if you're using mysql, or
select top number_rows
if you're using sql server.
see more here.
wiki
Comments
Post a Comment