locked
select query RRS feed

  • Question

  • Hi,

    Im trying to  do select  some organization under one name ,but I didnt get the query. Any suggestions please.

    if user select Progressive   I want to display Vonage,Verizon,GE Energy and if it is AT&T  then display Geico

    SELECT [Id]
          ,[Organization]
            FROM ClientManager
    
    result:
    Id      Organization
    26	Vonage	
    32	Verizon	
    25	GE Energy
    0	Geico	
    1	Progressive		
    2	AT&T	
    3	AT&T SE
    15	CapGem	
    20	TATA	
    41	Ericsson	
    43	Merut	
    45	Seizo	
    46	GE 	
    48	IBM	
    50	Microsoft


    • Edited by emaak Thursday, July 9, 2015 8:40 PM
    Thursday, July 9, 2015 8:39 PM

Answers

  • from what i understood.. may be this

    declare @ClientManager table(Id int,Organization varchar(20))
    
    insert into @ClientManager values (1,'Vonage'),(2,'Verizon')
    
    declare @userinput varchar(200)
    set @userinput='progressive'
    
    SELECT [Id]
          ,[Organization]
            FROM @ClientManager
            where (organization in ('Vonage','Verizon') and @userinput='progressive') or (organization in ('Geico') and @userinput='At&T')
    


    Hope it Helps!!

    • Proposed as answer by Katherine Xiong Friday, July 10, 2015 1:59 AM
    • Marked as answer by emaak Friday, July 10, 2015 5:40 PM
    Thursday, July 9, 2015 8:57 PM
    Answerer