helloworld21285
helloworld21285

Reputation: 1

SQL for case with Employee ID with two work locations

I need help with a view.

I have this one employee showing up twice right now because he has two work locations listed.

How can I put something into the view so it selects one location instead of both?

Example of data

EMPLID  Location
120032  NYC
120032  LAX
120021  NYC
120034  CHI

I want 120032 to only show his NYC when the view is executed.

Is putting something in the field formula better in app designer?

Upvotes: 0

Views: 227

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270723

For this example you can use aggregation:

select emplid, max(location) as location
from t
group by emplid;

This works on any database I am familiar with. Here is a db<>fiddle using MySQL.

Upvotes: 2

Related Questions