Click here to Skip to main content
14,873,377 members
Home / Discussions / Database
   

Database

 
GeneralRe: Check Different Select query result Pin
Naunt12-Aug-11 1:09
Member Naunt12-Aug-11 1:09 
GeneralRe: Check Different Select query result Pin
Wendelius12-Aug-11 2:38
mveWendelius12-Aug-11 2:38 
GeneralRe: Check Different Select query result Pin
Naunt12-Aug-11 0:50
Member Naunt12-Aug-11 0:50 
AnswerRe: Check Different Select query result Pin
Wendelius11-Aug-11 21:04
mveWendelius11-Aug-11 21:04 
GeneralRe: Check Different Select query result Pin
Naunt11-Aug-11 22:24
Member Naunt11-Aug-11 22:24 
AnswerRe: Check Different Select query result [modified] Pin
Wendelius11-Aug-11 23:04
mveWendelius11-Aug-11 23:04 
GeneralRe: Check Different Select query result Pin
Naunt12-Aug-11 0:56
Member Naunt12-Aug-11 0:56 
AnswerRe: Check Different Select query result Pin
Pascal Ganaye16-Aug-11 6:28
MemberPascal Ganaye16-Aug-11 6:28 
I don't know your data but you could try to get all your counts in one go using a CASE WHEN.
The COUNT aggregates only non null values.

SELECT 
	@result1 = COUNT(CASE WHEN (isNull(TDR_D20,0)= 0 And isNull(TDR_D40,0)=0 ...)	
		THEN 1 ELSE NULL END),
	@result2 = COUNT(CASE WHEN (isNull(TDR_D20,0)>0 Or isNull(TDR_H20,0)>0 ...)
		THEN 1 ELSE NULL END),
	@result3 = COUNT(CASE WHEN (isNull(TDR_D20,0)=0 AND isNull(TDR_H20,0)=0 ...))
		THEN 1 ELSE NULL END)
FROM table
WHERE Vessel_Code=@Vsl AND Voyage_No=@Voy AND POL=@POL 

This would be efficient as you would only read your table once this way.

Then the logic you can probably remove quite a bit of the begin end and it becomes (sometime) clearer.
IF @result1 = 20    SET @Color='Red Color'
Else IF @result2=20 SET @Color='Blue Color'
Else IF @result3>0  SET @Color='Blue Color'
Else IF @result4>0  SET @Color='Blue Color'
Else IF @result5=20 SET @Color='Green Color'
Else IF @result6>0  SET @Color='Yellow Color'
Else                    @Color='Orange Color'

QuestionSee this Pin
sivakumat11-Aug-11 1:20
Membersivakumat11-Aug-11 1:20 
QuestionCompare 3columns from a row with data Null value Pin
Naunt10-Aug-11 23:16
Member Naunt10-Aug-11 23:16 
AnswerRe: Compare 3columns from a row with data Null value Pin
Mycroft Holmes10-Aug-11 23:26
professionalMycroft Holmes10-Aug-11 23:26 
AnswerRe: Compare 3columns from a row with data Null value Pin
sujit076110-Aug-11 23:55
Membersujit076110-Aug-11 23:55 
GeneralRe: Compare 3columns from a row with data Null value Pin
Naunt11-Aug-11 0:18
Member Naunt11-Aug-11 0:18 
QuestionHELP !! Pin
Josh7harington10-Aug-11 5:14
MemberJosh7harington10-Aug-11 5:14 
AnswerRe: HELP !! Pin
Eddy Vluggen10-Aug-11 11:04
professionalEddy Vluggen10-Aug-11 11:04 
QuestionLoop in a Stored procedure Pin
lionelcyril9-Aug-11 20:50
Memberlionelcyril9-Aug-11 20:50 
AnswerRe: Loop in a Stored procedure Pin
Shameel9-Aug-11 22:20
professionalShameel9-Aug-11 22:20 
GeneralRe: Loop in a Stored procedure Pin
lionelcyril10-Aug-11 0:40
Memberlionelcyril10-Aug-11 0:40 
GeneralRe: Loop in a Stored procedure Pin
Shameel10-Aug-11 8:42
professionalShameel10-Aug-11 8:42 
GeneralRe: Loop in a Stored procedure Pin
lionelcyril10-Aug-11 8:46
Memberlionelcyril10-Aug-11 8:46 
GeneralRe: Loop in a Stored procedure Pin
S Douglas20-Aug-11 9:20
professionalS Douglas20-Aug-11 9:20 
AnswerRe: Loop in a Stored procedure Pin
jschell10-Aug-11 10:07
Memberjschell10-Aug-11 10:07 
QuestionInner Query in mysql Pin
Rakesh Meel8-Aug-11 0:56
professionalRakesh Meel8-Aug-11 0:56 
AnswerRe: Inner Query in mysql Pin
Simon Bang Terkildsen8-Aug-11 1:53
MemberSimon Bang Terkildsen8-Aug-11 1:53 
AnswerRe: Inner Query in mysql Pin
Simon_Whale8-Aug-11 2:49
professionalSimon_Whale8-Aug-11 2:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.