Fairly new to SQL, and I am a little stumped, though I bet the answer is easy.
I have the below query set up and results; but then need to ALSO pull another field in the same table [cicmpy] based on the column named "Dealer". I assume this is a subquery?
SELECT [cicntp].[cmp_wwn],[cicmpy].[syscreated] AS Date_Created,
[Cicmpy].[Cmp_code] AS code,
[cicmpy].[cmp_acc_man] AS RSM,
[cicmpy].[cmp_reseller] AS Dealer,
[cicntp].[cnt_f_name] AS First_Name,
[cicntp].[cnt_l_name] AS Last_Name,
[Cicmpy].[Cmp_name] AS Lead_Company_Name,
[Cicmpy].[cmp_type] AS Type,
[cicmpy].[cmp_fadd1] AS Street_Address,
[cicmpy].[cmp_fcity] AS City,
[cicmpy].[StateCode] AS State_Province,
[cicmpy].[cmp_fpc] AS Postal_Code,
[cicmpy].[cmp_fctry] as Country,
[cicmpy].[cmp_tel] as Phone_No,
[cicntp].[cnt_email] AS Email_Contact,
[cicmpy].[cmp_e_mail] AS Email_Company
FROM [TS-SQL2].[Synergy].[dbo].[cicmpy] left outer join [TS-SQL2].[Synergy].[dbo].[cicntp] on [cicmpy].[cmp_wwn] = [cicntp].[cmp_wwn]
Where [cicmpy].[cmp_type] = 'L' and YEAR({fn NOW()}) = YEAR([cicmpy].[syscreated]) and month({fn NOW()}) = month([cicmpy].[syscreated])
ORDER BY Lead_Company_Name
I have the below query set up and results; but then need to ALSO pull another field in the same table [cicmpy] based on the column named "Dealer". I assume this is a subquery?
SELECT [cicntp].[cmp_wwn],[cicmpy].[syscreated] AS Date_Created,
[Cicmpy].[Cmp_code] AS code,
[cicmpy].[cmp_acc_man] AS RSM,
[cicmpy].[cmp_reseller] AS Dealer,
[cicntp].[cnt_f_name] AS First_Name,
[cicntp].[cnt_l_name] AS Last_Name,
[Cicmpy].[Cmp_name] AS Lead_Company_Name,
[Cicmpy].[cmp_type] AS Type,
[cicmpy].[cmp_fadd1] AS Street_Address,
[cicmpy].[cmp_fcity] AS City,
[cicmpy].[StateCode] AS State_Province,
[cicmpy].[cmp_fpc] AS Postal_Code,
[cicmpy].[cmp_fctry] as Country,
[cicmpy].[cmp_tel] as Phone_No,
[cicntp].[cnt_email] AS Email_Contact,
[cicmpy].[cmp_e_mail] AS Email_Company
FROM [TS-SQL2].[Synergy].[dbo].[cicmpy] left outer join [TS-SQL2].[Synergy].[dbo].[cicntp] on [cicmpy].[cmp_wwn] = [cicntp].[cmp_wwn]
Where [cicmpy].[cmp_type] = 'L' and YEAR({fn NOW()}) = YEAR([cicmpy].[syscreated]) and month({fn NOW()}) = month([cicmpy].[syscreated])
ORDER BY Lead_Company_Name