-1

How can I make it so 2 Where conditions can be dependent For Example, a condition that has to go through a set of condition, and then find the value set on a condition within the condition prior

Here's the full syntax
SELECT 
RIGHT(s.Staff_ID, 3) AS [Staff Number],
Staff_FullName,
[Sales Transaction Date] = CONVERT(VARCHAR(30), SalesDate, 107),
[Total Quantity] = SUM(Quantity)

FROM
STAFF s
JOIN
SalesTransaction st
ON s.Staff_ID = st.Staff_ID

WHERE 
Staff_Country = 'China' AND
len(Staff_FullName) = (SELECT max(len(Staff_FullName)) FROM STAFF)


GROUP BY
s.Staff_ID,
Staff_FullName,
SalesDate

ORDER BY SUM (Quantity) ASC ```

How can I make it so it checks the longest value within the USA column?
Thank you in advance.
Moon
  • 1
  • 1

1 Answers1

0

Assuming Your database has the columns: table STAFF:

id (an Int)

Staff_Country (an String)

FullName (an String)

Staff_Name (an String)

You could use:

SELECT id,Staff_name,MAX(LEN(Full_Name)) 
FROM STAFF
WHERE Staff_Country = 'USA';

So in the end, is not necessary to use two where's

Tales
  • 36
  • 1
  • 4