0
Данные ниже, мне нужно выбрать col4 = 301 только для col2 = 1. Я получил данные после присоединения нескольких таблицы, используя запрос типа -case statement after statement statement в SQL
/****** Script for SelectTopNRows command from SSMS ******/
Select count(*),t.intWeightTypeId,t.locationid,t.airoccupancycode
from
(SELECT *
FROM [AIRWork].[dbo].[t1551_c1_LOSS_StagingLocation_0A578891-5DF8-4F77-8AC4-0A9480148F1F] a
join [AIRGeography].[dbo].[TblSourceTargetMap_US] b on a.guidareaexternal=b.guidExternalSource
where locationtypecode='R') t
group by t.intWeightTypeId,t.locationid,t.airoccupancycode
order by t.locationid
col1 col2 col3 col4
9 4 Loc_PE_14208 301
31 1 Loc_PE_14208 301
9 3 Loc_PE_14208 301
9 2 Loc_PE_14208 301
14 2 Loc_PE_14209 301
32 1 Loc_PE_14209 301
14 4 Loc_PE_14209 301
14 3 Loc_PE_14209 301
14 2 Loc_PE_14210 301
'где COL4 = 301 и col2 = 1'? не знаю, что вы получаете ... –
В чем вопрос? Почему бы вам просто не добавить инструкцию 'WHERE'? –