Click here to Skip to main content
15,895,283 members
Home / Discussions / Database
   

Database

 
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 
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 
My bad - that is what happens when you code without testing. Yes, the resulting columns in the THEN clauses would have to be in the aggregates.

Remove the INNER JOIN for the @tbl. Back to the Correlated Sub-queries but, on a much smaller table. I still think it will be much faster. Your first CASE would look like:

CASE 
   WHEN ((SELECT all_qy1_mo_commodity_total FROM @tmp where commodity = a.commodity) <> 0)
   THEN (sum(a.all_qy1_mo)/
      (SELECT all_qy1_mo_commodity_total FROM @tmp where commodity = a.commodity))*100.00 
   ELSE NULL 
END as [Column4]


When you created the index on the [country] column, did you include the [month] column in the same index? It should go from most restrictive to least restrictive to make sure that the query engine examines the least amount of index keys/rows as necessary.

There should be no reason why you can't get this query down to a second or so.
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 
AnswerRe: Brackets around column names? Pin
albCode17-Oct-06 0:15
albCode17-Oct-06 0:15 
GeneralRe: Brackets around column names? Pin
stevehnsn17-Oct-06 16:03
stevehnsn17-Oct-06 16:03 
QuestionError Upon Restoring Transaction Log Pin
toink toink16-Oct-06 20:19
toink toink16-Oct-06 20:19 
AnswerRe: Error Upon Restoring Transaction Log Pin
Mike Dimmick17-Oct-06 0:15
Mike Dimmick17-Oct-06 0:15 
QuestionSQl INNER JOIN ON 5 tables Pin
walalawll16-Oct-06 16:05
walalawll16-Oct-06 16:05 
AnswerRe: SQl INNER JOIN ON 5 tables Pin
walalawll16-Oct-06 16:36
walalawll16-Oct-06 16:36 

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.