sql server - SQL 2005 SELECT CASE <column> statement -


I appreciate the help with it, I get seriously stuck. Basically I have a table which

  SSS_DOWID name is Mars Mars Mercury Fri Sat Sun Details 2 MYNNNNNN Monday 3 MF YNNNYNN Monday, Friday .... ... 18 TNYNNNNN Tuesday .. ......  

I want to convert the values ​​into this table in the table which only

for the number of days of the same number, for example, 1 for Sunday, 2 for Monday, 3 for Tuesday, all way up to Sunday 8th.

So I want to do this a little bit of SQL:

  DECLARE @strDays table (SSS_DOWID int) @strDays select case (sun) when 'Y' then '1' When 'Y' and 'Y' then '4' and '' End + Case (Thu) when 'Y' then '3' and '' End + Case (Marriage) When 'When' 2 'er' y 'then' 5 'array' 'and + case (Fri) when' y 'and' 6 'from el' end '(case) when' y 'then' 7 'and' from the end [dbo ] .SSS_DOW (NOLOCK) Where SSS_DOWID IN (28,41,44) SELECT * FROM @strDays  

A combination of EXCEPT days, which works fine for personal days. So in this case, when I am in

28 (Mercury), 41 (Venus), and 44 (Sasun), I should be 4 (full), 6 (full) and 17 (oh nonsense)

1 and 7, separately).

Does anyone help me reorganize my SQL, so I get a table of 4, 6, 17

instead of 1, 4, 6 and 7?

Looks like you need an un-axis.

  Announcement @ tab (day difference primary key) found, enter int @ day (day, found), select 1, enter 0 days (day, found) Select 2, enter 0 days (day, received), select 3, enter 0 days (day IDE, found) 4, enter 0 days (day, found) Select 5 , Select 0 days enter (day, received) 6, enter 0 days (day, received), select 7, 0 - updated D SET d.found = 1 to @Da On ys de SSS_DOW S, when the case d.DayId = 1 and s.Mon == 'Y' then 1 ibi d. DID = 2 and S. TU == 'Y' then 1 WHEN D.DayId = 3 and s.Wed == 'Y' then 1 when d. DID = 4 and S. Thu == 'Y' then 1 when d. DID = 5 and S. Fry == 'Y' then 1 when d. Diode = 6 and S. Set == 'Y' then 1 ibi d. Diad = 7 and S. Sun == 'Y' then 1E LSE 0 END = 1 where in SSS_DowID (28, 41, 44) - SELECT * FROM @days found WHERE = 1  

Comments