Can anyone help me fix this query ?

Results 1 to 2 of 2

Thread: Can anyone help me fix this query ?

  1. #1
    Join Date
    Dec 1969

    Default Can anyone help me fix this query ?

    Can Anyone help in this query which performs action on 2 tables?<BR><BR>1st table contains data as follows<BR><BR>TaxAreaAuthority<BR><BR>taxauthorit y tax area<BR>‘city1’ ‘city1’<BR>‘city2’ ‘city2’<BR>‘city3’ ‘city3’<BR>‘county1’ ‘city1’<BR>‘county1’ ‘city2’<BR>‘county2’ ‘city3’<BR>‘state1’ ‘city1’<BR>‘state1’ ‘city2’<BR>‘state1’ ‘city3’<BR><BR>2nd table contains data as follows<BR><BR>TaxRates<BR><BR>taxauthority dteffetive authtaxrate<BR>‘city1’ ‘1993-01-01’ 1.0<BR>‘city1’ ‘1994-01-01’ 1.5<BR>‘city2’ ‘1993-09-01’ 1.5<BR>‘city2’ ‘1994-01-01’ 2.0<BR>‘city2’ ‘1995-01-01’ 2.5<BR>‘city3’ ‘1993-01-01’ 1.7<BR>‘city3’ ‘1993-07-01’ 1.9<BR>‘county1’ ‘1993-01-01’ 2.3<BR>‘county1’ ‘1994-10-01’ 2.5<BR>‘county1’ ‘1995-01-01’ 2.7<BR>‘county2’ ‘1993-01-01’ 2.4<BR>‘county2’ ‘1994-01-01’ 2.7<BR>‘county2’ ‘1995-01-01’ 2.8<BR>‘state1’ ‘1993-01-01’ 0.5<BR>‘state1’ ‘1994-01-01’ 0.8<BR>‘state1’ ‘1994-07-01’ 0.9<BR>‘state1’ ‘1994-10-01’ 1.1<BR><BR>This table is used for answering problems such as “What is the total tax rate for city2 on November 1, 1994?” for the tax collector. The answer for this particular question would be<BR><BR>City2 taxrate =2.0<BR>County1 taxrate =2.5<BR>State1 taxrate =1.1<BR>TotalTaxRate =5.6<BR><BR>Can you write a single SQL query to answer this question?<BR><BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Is this homework?

    Looks suspiciously like it.<BR><BR>So how about just a hint instead of the answer:<BR><BR>AGGREGATES.<BR><BR>Look up "Aggregates" in SQL Server HELP docs (or online at MSDN).<BR><BR>Doing the date part right might be the toughest part. The problem is that the TaxRates table doesn&#039;t have a "dteEndOfEffective" field. Personally, first thing I would do would be to add that field to the table and fill in the dates for it. Doing so would improve performance of lots of other queries, not just this one.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts