Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

choosing multiple options

$
0
0
Hi, I have a table and I am having a hard time understanding how to write the code. :w00t:The final user needs to be able to choose the following.one or many "population"one or many indicators, meaning he can choose only ind_1, ind_2 or a combination of the columns, the original table has more than two columns.depending on what the final user choose i need to calculate the amount sent taking in consideration where the indicator is 1 or 0.my problem is1) how can i choose the population of the indicator.if i choose population a, i will subdivide the users in ind_1 into two groups, good group where they have a 0 and bad group where they have a 1, and i will calculate the spending.but if the user choose more than one indicator, how do i tell the table what to calculate, the more indicators i have the the more options to combine them. this is the sample tablethanks[code="sql"]create table panel(population nvarchar(2),userid int,ind_1 smallint,ind_2 smallint,amountspent float)insert into panel (population, userid, ind_1, ind_2 ,amountspent) values ('a' ,1, 1, 0, 1110),('a' ,2, 0, 1, 1372),('a' ,3, 1, 0, 1331),('a' ,4, 0, 0, 1921),('a' ,5, 1, 0, 1559),('a' ,6, 1, 0, 1166),('a' ,7, 1, 1, 1128),('a' ,8, 1, 0, 1597),('a' ,9, 0, 0, 1185),('a' ,10, 0, 0, 1900),('a' ,11, 0, 1, 1007),('a' ,12, 0, 1, 1183),('a' ,13, 0, 1, 1509),('b' ,14, 1, 0, 1226),('b' ,15, 1, 0, 1428),('b' ,16, 0, 0, 1988),('b' ,17, 1, 1, 1778),('b' ,18, 1, 0, 1561),('b' ,19, 1, 1, 1448),('b' ,20, 1, 0, 1340),('b' ,21, 1, 1, 1682),('b' ,22, 1, 1, 1744),('b' ,23, 0, 0, 1072),('b' ,24, 1, 0, 1580),('b' ,25, 0, 0, 1819),('b' ,26, 1, 0, 1785),('b' ,27, 0, 1, 1240),('c' ,28, 0, 1, 1947),('c' ,29, 1, 1, 1374),('c' ,30, 0, 0, 1031),('c' ,31, 1, 0, 1412),('c' ,32, 0, 0, 1447),('c' ,33, 1, 0, 1146),('c' ,34, 1, 0, 1011),('c' ,35, 0, 0, 1200),('c' ,36, 0, 1, 1974),('c' ,37, 0, 0, 1898),('c' ,38, 0, 1, 1856),('c' ,39, 0, 1, 1810),('c' ,40, 1, 0, 1059),('d' ,41, 0, 1, 1020),('d' ,42, 0, 0, 1273),('d' ,43, 0, 1, 1569),('d' ,44, 0, 1, 1288),('d' ,45, 1, 1, 1257),('d' ,46, 0, 1, 1245),('d' ,47, 0, 0, 1094),('d' ,48, 1, 0, 1324),('d' ,49, 0, 1, 1851),('d' ,50, 0, 1, 1776),('d' ,51, 1, 0, 1657),('d' ,52, 1, 1, 1375),('d' ,53, 0, 1, 1262),('d' ,54, 1, 0, 1021),('d' ,55, 1, 0, 1582),('d' ,56, 1, 0, 1068),('d' ,57, 0, 1, 1617),('d' ,58, 1, 1, 1746)select * from panel[/code]

Viewing all articles
Browse latest Browse all 3145

Trending Articles