test sql

0

Please login or register to vote for this query.

(click on this box to dismiss)

Physical Fitness Meta

Q&A about the site for physical fitness professionals, athletes, trainers, and those providing health-related needs

declare @table table
(mark int, 
name varchar(10), 
cost int, 
salecategory int, 
costcategory int)

insert @table values(10, 'pete', 20, '9', '9')
insert @table values(10, 'pete', 20, '6', '6')
insert @table values(15, 'pete', 20, '5', '6')
insert @table values(10, 'pete', 56, '6','2')
insert @table values(15, 'John', 10, '7','3')
insert @table values(20, 'John', 10, '2','1')
insert @table values(20, 'John', 10, '1','1')

SELECT 
*
			, CASE WHEN costcategory = salecategory THEN 1 ELSE 0 END AS same_category_sales
            , CASE WHEN (costcategory IN (1,2,3,5,6,9,7)) AND (salecategory IN (7,1,2,3,5,6,9)) THEN 1 ELSE 0 END AS crp_seller_sales
            from @table

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results