I have data that looks similar to this:
ID | Order# | Transfer#
1 | Abc | 123a
2 | Abc | 456b
3 | Abc | 123a
4 | Abc | NULL
5 | Def | 123c
6 | Def | 456d
7 | Def | 123c
8 | Def | NULL
I want to run a query that returns 1 row, and it doesn't matter which transfer# is chooses (except the null).
If I run this query:
SELECT order#,
transfer#
FROM coitem
WHERE order# ='abc'
AND transfer# IS NOT NULL
GROUP BY order# ,
transfer#
It returns:
Order# | Transfer#
Abc | 123a
Abc | 456b
Def | 123c
Def | 456d
Is there a way to only return 1 row, either like this:
Order# | Transfer#
Abc | 456b
Def | 123c
My goal is to view top 1 transfer# for all orders in my system, with one query.
Thanks