Click here to Skip to main content
15,924,036 members
Home / Discussions / Database
   

Database

 
AnswerRe: Saving date time! Pin
Mike Dimmick19-Oct-06 6:53
Mike Dimmick19-Oct-06 6:53 
AnswerRe: Saving date time! Pin
BlueBrother19-Oct-06 8:28
BlueBrother19-Oct-06 8:28 
QuestionTo find dependencies of a table Pin
rahuljosh007200017-Oct-06 18:22
rahuljosh007200017-Oct-06 18:22 
AnswerRe: To find dependencies of a table Pin
Aby Thomas Varghese18-Oct-06 9:13
Aby Thomas Varghese18-Oct-06 9:13 
GeneralRe: To find dependencies of a table Pin
rahuljosh007200018-Oct-06 21:03
rahuljosh007200018-Oct-06 21:03 
Questionsaving tables that are generated by queries as HTML file or sub-tables Pin
miamikk17-Oct-06 11:15
miamikk17-Oct-06 11:15 
AnswerRe: saving tables that are generated by queries as HTML file or sub-tables Pin
Michael Potter17-Oct-06 12:04
Michael Potter17-Oct-06 12:04 
GeneralRe: saving tables that are generated by queries as HTML file or sub-tables Pin
miamikk17-Oct-06 12:20
miamikk17-Oct-06 12:20 
Actual query looks like below:
Column 7 computation is the killer since column7=column5/column4. column4 & column5 part runs twice here. I dont know if I can save column4 & 5 values in a variables and then compute column7 value just using the variables. That will save half of the time. Can it be done ??

Use test
Go
Declare @Country Int, @Month Int
Set @Country=5310
Set @Month=12

select top 10 a.commodity, sum(a.all_qy1_mo) as Quantity, sum(a.all_val_mo) as [Value],

CASE WHEN (select Sum(b.all_qy1_mo)from [2005exp] b
where a.commodity=b.commodity)<>0 THEN (sum(a.all_qy1_mo)/(select
Sum(b.all_qy1_mo) from [2005exp] b
where a.commodity=b.commodity))*100.00 ELSE NULL END as [Column4],

CASE WHEN (select sum(b.all_val_mo) from [2005exp] b
where a.commodity=b.commodity)<>0 THEN (sum(a.all_val_mo)/(select
sum(b.all_val_mo) from [2005exp] b
where a.commodity=b.commodity))*100.00 ELSE NULL END as [Column5],

CASE WHEN sum(a.all_qy1_mo)<> 0 THEN
sum(a.all_val_mo)/sum(a.all_qy1_mo) ELSE NULL END as [Average Price],

CASE WHEN (select Sum(b.all_qy1_mo)from [2005exp] b
where a.commodity=b.commodity)<>0 THEN
(((sum(a.all_val_mo)/(select sum(b.all_val_mo) from [2005exp] b
where a.commodity=b.commodity)))/((sum(a.all_qy1_mo)/(select
Sum(b.all_qy1_mo) from [2005exp] b
where a.commodity=b.commodity)))) ELSE NULL END as [Column7]

from [2005exp] a inner join concord c on a.commodity=c.commodity
WHERE a.cty_code=@Country and a.stat_month=@Month
GROUP BY a.commodity, c.descrip_1, c.quantity_1
order by [Value] desc
GeneralRe: saving tables that are generated by queries as HTML file or sub-tables Pin
Eric Dahlvang18-Oct-06 3:09
Eric Dahlvang18-Oct-06 3:09 
GeneralRe: saving tables that are generated by queries as HTML file or sub-tables Pin
miamikk18-Oct-06 4:10
miamikk18-Oct-06 4:10 
GeneralRe: saving tables that are generated by queries as HTML file or sub-tables Pin
Eric Dahlvang18-Oct-06 5:02
Eric Dahlvang18-Oct-06 5:02 
GeneralRe: saving tables that are generated by queries as HTML file or sub-tables Pin
Michael Potter18-Oct-06 3:34
Michael Potter18-Oct-06 3:34 
GeneralRe: saving tables that are generated by queries as HTML file or sub-tables Pin
miamikk18-Oct-06 4:16
miamikk18-Oct-06 4:16 
GeneralRe: saving tables that are generated by queries as HTML file or sub-tables Pin
Michael Potter18-Oct-06 4:46
Michael Potter18-Oct-06 4:46 
QuestionClearing the LOG file ?!! Pin
devboycpp17-Oct-06 8:18
devboycpp17-Oct-06 8:18 
AnswerRe: Clearing the LOG file ?!! Pin
Mike Dimmick17-Oct-06 11:37
Mike Dimmick17-Oct-06 11:37 
QuestionSelect statement on Cursor Pin
Jens Meyer17-Oct-06 4:27
Jens Meyer17-Oct-06 4:27 
AnswerRe: Access or SQL Express?? Pin
Jim Conigliaro17-Oct-06 4:26
Jim Conigliaro17-Oct-06 4:26 
AnswerRe: Access or SQL Express?? Pin
stevehnsn17-Oct-06 15:53
stevehnsn17-Oct-06 15:53 
QuestionAccess or SQL Express?? Pin
quinton.nel17-Oct-06 0:25
quinton.nel17-Oct-06 0:25 
AnswerRe: Access or SQL Express?? Pin
Colin Angus Mackay17-Oct-06 0:59
Colin Angus Mackay17-Oct-06 0:59 
GeneralRe: Access or SQL Express?? Pin
quinton.nel17-Oct-06 1:21
quinton.nel17-Oct-06 1:21 
GeneralRe: Access or SQL Express?? Pin
Jerry Hammond18-Oct-06 4:13
Jerry Hammond18-Oct-06 4:13 
QuestionBrackets around column names? Pin
quinton.nel16-Oct-06 23:47
quinton.nel16-Oct-06 23:47 
AnswerRe: Brackets around column names? Pin
Mike Dimmick17-Oct-06 0:14
Mike Dimmick17-Oct-06 0:14 

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.