*Please* send your followups to the list. This enables others to help rather
than placing the burden solely on me. It also ensures that the conversation,
including the solution, appear in the mailing list archives where they can
be of benefit to others down the road. If you want to copy me on your
followup, that is okay.

Rhino

----- Original Message ----- 
From: "Andrew Kuebler" <[EMAIL PROTECTED]>
To: "'Rhino'" <[EMAIL PROTECTED]>
Sent: Wednesday, October 13, 2004 12:10 PM
Subject: RE: SELECT SUM + 2 JOINS


Here is a snapshot of the order contents:

mysql> SELECT * FROM OrderContents WHERE OrderID = 3116;
+-----------+---------+-------------+---------------+-----+----------+------
---------------+
| ContentID | OrderID | InventoryID | Price         | Qty | QtyAvail |
ShipDate            |
+-----------+---------+-------------+---------------+-----+----------+------
---------------+
|      2425 |    3116 |         317 | 19.5000000000 |   1 |        1 |
2004-09-21 13:44:34 |
|      2426 |    3116 |         347 | 19.5000000000 |   1 |        1 |
2004-09-21 13:44:34 |
|      2427 |    3116 |         367 | 19.5000000000 |   1 |        1 |
2004-09-21 13:44:34 |
|      2428 |    3116 |         587 | 31.5000000000 |   1 |        1 |
2004-09-21 13:44:34 |
|      2429 |    3116 |         627 | 31.5000000000 |   1 |        1 |
2004-09-21 13:44:34 |
|      2430 |    3116 |         923 | 38.5000000000 |   1 |        1 |
2004-10-05 12:30:43 |
|      2431 |    3116 |        1199 | 42.5000000000 |   1 |        1 |
2004-09-30 10:28:18 |
|      2432 |    3116 |        1236 | 44.5000000000 |   1 |        1 |
2004-10-05 12:30:43 |
|      2433 |    3116 |        1263 | 44.5000000000 |   1 |        1 |
2004-09-21 13:44:34 |
|      2434 |    3116 |        1492 | 46.5000000000 |   1 |        1 |
2004-10-05 12:30:43 |
|      2435 |    3116 |        1505 | 38.5000000000 |   1 |        1 |
2004-10-05 12:30:43 |
+-----------+---------+-------------+---------------+-----+----------+------
---------------+

Here is a snapshot of the charge details:

mysql> SELECT ANID, PaymentID, OrderID, ApprovalCode, Amount,
TransactionType FROM AuthorizeNet WHERE OrderID = 3116;
+------+-----------+---------+--------------+--------+--------------------+
| ANID | PaymentID | OrderID | ApprovalCode | Amount | TransactionType    |
+------+-----------+---------+--------------+--------+--------------------+
| 2188 |       660 |    3116 | 165627       | 183.00 | prior_auth_capture |
| 2832 |       660 |    3116 | 127447       |  42.50 | auth_capture       |
| 3379 |       660 |    3116 | 164026       | 168.00 | auth_capture       |
+------+-----------+---------+--------------+--------+--------------------+
6 rows in set (0.01 sec)

I'm trying to get the two total amounts by OrderID in 1 Query...

Best Regards,

Andrew Kuebler
AK Communications, Inc.
Phone: (866) 925-2666 x123 / Fax: 866-925-3296 (Toll-free)
http://www.akcomm.com


-----Original Message-----
From: Rhino [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 13, 2004 11:32 AM
To: Andrew Kuebler; [EMAIL PROTECTED]
Subject: Re: SELECT SUM + 2 JOINS

It's awfully hard for anyone to help without seeing the SQL that you are
trying to execute. Ideally, the full descriptions of the tables involved and
a few rows of sample data would make it a lot easier for us to be able to
visualize what you are doing but you sometimes get a useful answer from the
SQL alone.

The other thing that is vital for a good answer to this kind of question is
knowing which version of MySQL you are running; later versions have much
greater SQL capabilities than earlier versions.

Rhino

----- Original Message ----- 
From: "Andrew Kuebler" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 13, 2004 11:22 AM
Subject: SELECT SUM + 2 JOINS


> I have a MySQL table with Order#'s (Primary Key).
>
>
>
> I want to total the number of items per order which I do through an inner
> join to the order contents, but then I want to also get a total on the
> amounts a customer has been billed to make sure there isn't a customer
that
> has been shipped something they haven't paid for. Everything is ok until I
> do the left join on the payments which there could be more than one of for
> each order. Is it possible to do what I am asking in one query?
>
>
>
> I hope I have made sense.
>
> Best Regards,
>
> Andrew
>
>
>
>


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to