To add to the other answers here, you have at least the following options:
If the other question is good and already has good answers that fully solve your problem, just let your question be marked as a duplicate.
If you feel that the answer(s) posted to your question are also good and should be rewarded, you can still upvote them and even mark one of them as accepted. As durron597 notes, your question and its answers will not be automatically deleted, and they'll even be linked from the sidebar of the other question.
If the two questions happen to be exact duplicates, so that the answers to your question would also make sense as answers to the other one, and if you feel that moving them to the other question would actually improve it, you can ask a ♦ mod to merge the questions by flagging you question and using the "Other..." option to explain what you think should be done and why that would be a good idea.
If the questions are technically duplicates, but you feel that your question is significantly better asked and has better answers, you can also counter-flag the other question as a duplicate of yours. This is a perfectly valid option, although you shouldn't overuse it — consider the other options too, and try to keep in mind that you may not always be the most objective person to judge the relative merits of the questions. If you do decide to use this option, it's often a good idea to leave a comment on the other question explaining why you feel that it should be closed as a duplicate of yours, and not vice versa.
Conversely, if the other question is poorly asked (e.g. full of irrelevant details), but the answers are great, you could edit the other question to improve it, and then let yours be marked as a duplicate of the edited question.
If both questions are reasonably well asked and answered, but the questions and answers approach the same problem from somewhat different viewpoints, that might be a sign that the questions are not really exact duplicates after all. In that case, it could be perfectly fine to let them both stay open, but linked through the sidebar. (Any link from one of the question threads to the other, even from comments, will automatically add such a sidebar link.) If someone has already voted / flagged your question as a duplicate, you may wish to post a comment explaining why you think it's different enough to stay open. Then just let the reviewers decide.
All that said, there's also one more option: find a third question that covers the same subject better than either of yours, and flag both questions as duplicates of that one.
In your case, I think this one might be the best choice — both your question and the suggested duplicate are variations on a very common question that has been asked on SO many, many times already. The "definitive" instance of your specific question is probably this one, although this and this question also cover then same topic from a more abstract viewpoint. (Some of those might themselves be dupes of each other, but again, it's perfectly fine to have a several near-duplicates of a common question, especially if all of them have good answers.)
BTW, one good way to find such "definitive" questions is to pick a few relevant keywords, put them in the search box, and sort the results by score. The best, most definitive examples of common questions tend to steadily gather upvotes, putting them near the top of the list. For example, I found the questions linked above by searching for [sql] where having count.