我只想要一个国家一排?

时间:2017-09-27 11:22:19

标签: sql sql-server

我想只有一个国家/地区。

我加入了两个专栏。

SELECT  
    brief_title AS Title,
    study_type  AS [Study Type],
    location_countries_country + location_facility_address_country AS Country,
FROM 
    [dbo].[ClinicalTrialStaging] 
WHERE
    study_type = 'all' 
    AND (location_countries_country LIKE '%United States%' OR 
         location_facility_address_country LIKE '%United States%')

我得到了这个结果:

Country
----------------------------
United States|United States|
United States|United States|
United States|United States|

我在同一行有两个国家/地区,但我只想要一个国家/地区

1 个答案:

答案 0 :(得分:0)

我认为您正在寻找的是

    GROUP BY country

示例:

    location_countries_country + location_facility_address_country AS Country 
    from customer         
    WHERE (location_countries_country like '%United States%' or 
    location_facility_address_country like '%United States%')
    GROUP BY Country