HELP PLEASE: URGENT: Need help forming a multi table query

HELP PLEASE: URGENT: Need help forming a multi table query

Post by Ayaz As » Wed, 07 Jun 2000 04:00:00



Hello,

I'm using SQL SERVER 7.0. I'm very new to Multi-Table querying, and
can't seem to figure this one out. Any help would be appreciated.

I have 2 tables. one is called RATES and one is called BILLING

In the BILLING table, there are 2 columns, one is COUNTRY and
the other is ACTUAL.  In the RATES table, there are two columns
COUNTRY (which you would use to match the rate to) and RATE.

This is for an ASP page. It has to go row by row of the BILLING
table and calculate the total of a phone call, by multiplying the
ACTUAL of BILLING column with the RATE for that COUNTRY.
It sounds simple, but I get strange (wrong) results everytime.

Any help would be appreciated.  Thanks in advance.

Ayaz Asif

 
 
 

HELP PLEASE: URGENT: Need help forming a multi table query

Post by Shawn Clar » Wed, 07 Jun 2000 04:00:00


Ayaz,

As long as there is only one record for each country in the RATES table then
you could try something like:

SELECT Billing.Country, Billing.Actual, Rates.Rate, ActualRate =
Billing.Actual * Rates.Rate
FROM Billing JOIN Rates ON Billing.Country = Rates.Country

The join will allow you to associate the BILLING table to the RATES table
based on the key of COUNTRY. The reason why I stated that there should only
be one record for each country in the RATES table is so that only one record
from the BILLING table would be in the result set.

--
Shawn Clark
Senior Software Consultant
Meridian Technology Group


> Hello,

> I'm using SQL SERVER 7.0. I'm very new to Multi-Table querying, and
> can't seem to figure this one out. Any help would be appreciated.

> I have 2 tables. one is called RATES and one is called BILLING

> In the BILLING table, there are 2 columns, one is COUNTRY and
> the other is ACTUAL.  In the RATES table, there are two columns
> COUNTRY (which you would use to match the rate to) and RATE.

> This is for an ASP page. It has to go row by row of the BILLING
> table and calculate the total of a phone call, by multiplying the
> ACTUAL of BILLING column with the RATE for that COUNTRY.
> It sounds simple, but I get strange (wrong) results everytime.

> Any help would be appreciated.  Thanks in advance.

> Ayaz Asif



 
 
 

1. URGENT help please - need to limit results with multi table join

Hello,
I've posted to other groups, but I don't get any replies for this problem! I
wonder if anyone could help here.  If people think it's not possible, then
please say! at least I will know.

Okay, I have two tables (for example), with a one to many relationship.

TABLE helpers
ID (primary key)
Firstname
Lastname

TABLE helpareas
areaID (Primay Key)
ID (Foreign Key)
Description

My select query would go something like:
SELECT firstname, lastname, description
FROM helpers, helpareas
WHERE helpers.ID = helpareas.ID

Now, because I could have different numbers of rows in helpareas, I can't
simply put a LIMIT on the rows. So if I want to select only the first 10
helpers, I can't put LIMIT at the end because it would only retrieve the
first 10 joined rows.  So, is there any way of overcoming this? What about
telling my anywhere else to look? ANYTHING would be appreciated!

P.S. I'm restricted to using mySQL (for now), so subqueries are out of the
question.

Thanks in advance,

Michael

2. DatabaseMetaData problem?

3. HELP: URGENT: MULTI-TABLE Query (SQL7)

4. ODBC Error while executing commands.

5. Help please with multi-table query

6. Can't Delete DTS package

7. Urgent help needed please help

8. pgsql-server/ /configure.in ontrib/contrib-glo ...

9. Newbies need help.........Urgent please help.....!!

10. Please Help Urgent help needed!!!!

11. Newbies need help......Urgent please help!!

12. Need help trying to set up Query across multi tables

13. HELP: Toggle between tables in multi-table form in PdoxWIN