Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
protest
Starting Member
7 Posts |
Posted - 2008-01-13 : 02:52:27
|
need help- how to tricky select with checking columns value (count an check)i need to do this checking columns end add One row at the end !my table empid name date val1 val2------------------------------------------------------------------------------------------ 1111 aaaa 01/01/2008 1 02222 bbbb 01/01/2008 0 03333 cccc 01/01/2008 1 24444 dddd 01/01/2008 2 15555 eeee 01/01/2008 3 36666 ffff 01/01/2008 2 0-----------------------------------------------------------------------------------------condition for VAL1+val2if no twice 3than miss(3) if eny zerothan miss('*') if no twice 1than miss('1') if no triplet 2than miss('2') if only one 3than miss('3') if no six employeethan miss('$') if all okthan miss('OK') need to get this result empid name date val1 val2------------------------------------------------------------------------------------------ 1111 aaaa 01/01/2008 1 02222 bbbb 01/01/2008 0 03333 cccc 01/01/2008 1 24444 dddd 01/01/2008 2 15555 eeee 01/01/2008 3 36666 ffff 01/01/2008 2 0# # # miss(1,_,_,_) miss(1,3,4,_,_)thanks-----------------------if this can help i find it----------------------------Create table #Data(ValueColumn varchar(100)) Insert Into #Data Values(' ');Insert Into #Data Values('');Insert Into #Data Values(' ');Insert Into #Data Values(' ');Insert Into #Data Values(NULL);Insert Into #Data Values('Some value');Select Case When ValueColumn='' Then '(Empty)' Else ValueColumn End From #Data |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-13 : 05:06:23
|
| Sorry cant get much from your explanation. Can you tell clearly what you really want? |
 |
|
|
protest
Starting Member
7 Posts |
Posted - 2008-01-13 : 05:53:10
|
| i need to do COUNT and check columnsand the result put in the LAST ROWid ValueColumn---------------------------------111 1222 1333 1 444 2555 2now i need to check the all the column in this exampletwice times 2 IT OKand 3 times 3 it NOT OKSelect Case When ValueColumn=1 count*<2 Else miss('2')Select Case When ValueColumn=1 count*=0 Else miss('2') Select Case When ValueColumn=2 count*<1 Then miss('3') need to see like thisid ValueColumn---------------------------------111 1222 1333 1 444 2555 2-------------### miss(1,2_,_,_) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-14 : 02:30:47
|
| Where do you want to show data?If you use front end application, do this check and display result accordinglyMadhivananFailing to plan is Planning to fail |
 |
|
|
protest
Starting Member
7 Posts |
Posted - 2008-01-14 : 16:04:38
|
| i need to put the result in the last ROWon field val1 i need to see the result on the last row of val1on field val2 i need to see the result on the last row of val2val1----------123011MISS(2,3,4)-----if i don'T have twice 1 than =miss('1')if i don'T have twice 2 than =miss('2')if i don'T have twice 3 than =miss('3')i have 0 than =*TNX |
 |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2008-01-14 : 16:24:01
|
| who is miss? |
 |
|
|
protest
Starting Member
7 Posts |
Posted - 2008-01-14 : 17:57:20
|
| miss = result of the conditionif no twice 3than ####(3) |
 |
|
|
|
|
|
|
|