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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 checking columns end add One row at the end

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 0

2222 bbbb 01/01/2008 0 0

3333 cccc 01/01/2008 1 2

4444 dddd 01/01/2008 2 1

5555 eeee 01/01/2008 3 3

6666 ffff 01/01/2008 2 0

-----------------------------------------------------------------------------------------
condition for VAL1+val2


if

no twice 3

than miss(3)



if

eny zero

than miss('*')



if

no twice 1

than miss('1')



if

no triplet 2

than miss('2')



if

only one 3

than miss('3')



if

no six employee

than miss('$')



if

all ok

than miss('OK')


need to get this result



empid name date val1 val2

------------------------------------------------------------------------------------------

1111 aaaa 01/01/2008 1 0

2222 bbbb 01/01/2008 0 0

3333 cccc 01/01/2008 1 2

4444 dddd 01/01/2008 2 1

5555 eeee 01/01/2008 3 3

6666 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?
Go to Top of Page

protest
Starting Member

7 Posts

Posted - 2008-01-13 : 05:53:10
i need to do COUNT and check columns
and the result put in the LAST ROW

id ValueColumn
---------------------------------
111 1
222 1
333 1
444 2
555 2

now i need to check the all the column
in this example
twice times 2 IT OK
and 3 times 3 it NOT OK

Select 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 this

id ValueColumn
---------------------------------
111 1
222 1
333 1
444 2
555 2
-------------
### miss(1,2_,_,_)

Go to Top of Page

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 accordingly

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

protest
Starting Member

7 Posts

Posted - 2008-01-14 : 16:04:38
i need to put the result in the last ROW
on field val1 i need to see the result on the last row of val1

on field val2 i need to see the result on the last row of val2

val1
----------
1
2
3
0
1
1

MISS(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
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2008-01-14 : 16:24:01
who is miss?
Go to Top of Page

protest
Starting Member

7 Posts

Posted - 2008-01-14 : 17:57:20
miss = result of the condition

if

no twice 3

than ####(3)
Go to Top of Page
   

- Advertisement -