MSFN Forum: SQL Query - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

SQL Query Rate Topic: -----

#1 User is offline   Cyrius 

  • Newbie
  • Group: Members
  • Posts: 41
  • Joined: 10-October 11
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 28 February 2012 - 08:01 AM

Hi guys, I was wondering if you could give me a hand with an SQL query, I am rusty.

I need to show a user's name rather than the integer for their name. For example, the code below is showing 318512 as the user for inside sales on a customer.

I got the key relationship set up right (I think) but I need the columns Inside Sales and Outside sales to show U.First_Name+U.Last_Name.

One other confusing me is the foreign key being tied to two fields.

I used the left outer join because there are some null values in the customer table for both Inside and Outside sales.

SELECT
C.Name AS 'Customer Name',
C.Customer_Status,
C.Customer_Type,
C.Phone,
C.Fax,
C.Out_Sales AS 'Outside Sales',
C.In_Sales AS 'Inside Sales'
FROM Customer AS C LEFT OUTER JOIN User AS U
ON C.Out_Sales = U.User_No
AND C.In_Sales = U.User_No
WHERE Customer_Type = 'Retail'


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy