This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Originally posted by Abigail Moore: I have the following sql:
SELECT customer_id, hierarchy_id, hierarchy_type_cd, primary_station, primary_type_cd FROM ebat.ha_station_hierarchy_811 WHERE customer_id = '9999999999' AND primary_station = '5629402401'
This returns 2 rows of data where primary_type_cd is different. How do I change this sql so that it rolls the 2 rows of data into 1, ignoring the difference in the primary_type_cd?
Thanks for the help
Note the addition of the DISTINCT keyword, and the removal of the primary_type_cd column from the selection criteria; since there are two different values and you want just one row, you either have to pick a particular value of primary_type_cd or omit it.
An example of picking one of the primary_type_cd values is:
The success of this SQL depends on what your database actually supports and the actual data type of the primary_type_cd column; it might not work for you on your particular database, but something else along those lines will.
Joined: May 13, 2004
Thank you! I will try that, I did try distinct but didn't remove primary_type_cd.