For example, I have a table with multiple order number and each order number has multiple itemnum
. Then, each order number has same item but some order number has only one item. How can I get them?
How can I get the ordernum
with itemnum
123456 only?
with select ordernum from table where itemnum=123456
It displays me all ordernum
with that itemnum
but not the ordernum
containing only that itemnum
2
Answers
It will be solved by using SQL
HAVING
clause.HAVING COUNT(ordernum) = 1 AND itemnum = 123456
ensures that only ordernum with a single record has itemnum 123456 Try this:You can try a nested subquery like this: