我对SQL还是很陌生,以下代码有问题:
SELECT
in_profiles.profiles AS IncludeProfiles
,no_profiles.profiles AS ExcludeProfiles
, data.*,
CASE
WHEN data.travel_type NOT LIKE 'car' THEN data.reason_code <> 'PT' ELSE
END CASE
FROM transportation_data data
答案 0 :(得分:0)
您可以使用where子句确定要返回的内容。在这种情况下,如此给定的汽车原因代码似乎无关紧要
Total - (OnesInCol[0] + OnesInCol[1] ), OnesInCol[0] + OnesInCol[1]
查询看起来像这样
int count = 0;
int prevOnes = 0;
int onesInRowAboveThisCut = 0;
for ( int i = 1; i < rows; i++ ) {
onesInRowAboveThisCut = prevOnes + OnesInRow[i-1];
if ( onesInRowAboveThisCut= total/2 ) count++;
prevOnes = onesInRowAboveThisCut;
}
prevOnes = 0;
int onesInColBeforeThisCut = 0;
for ( int i = 1; i < cols; i++ ) {
onesInColBeforeThisCut = prevOnes + OnesInCol[i-1];
if ( onesInColBeforeThisCut = total/2 ) count++;
prevOnes = onesInColBeforeThisCut ;
}
return count;
结果
drop table if exists transportation_data;
create table transportation_data (travel_type varchar(10), reason_code varchar(3));
insert into transportation_data values
('car','pt'),('car','xx'),
('bus','pt'),('bus','xx');
或者可能是
SELECT data.*
FROM transportation_data data
where travel_type = 'car' or (travel_type <> 'car' and reason_code <>'pt')
取决于口味