MySQL Forums
Forum List  »  Newbie

Multiple selects from same table
Posted by: Safi Fehl
Date: August 03, 2015 02:37PM

Is that possible by using only sql to get the following output for each of platID currency relation from below table?

Simplified wanted view

+-----------+-----------------+------------------+-----------------+------------------+
| timestamp | plat 1 USD buy | plat 1 USD sell | plat 2 USD buy | plat 2 USD sell |
+-----------+-----------------+------------------+-----------------+------------------+
| 13:44 | 3.7589 | 3.7889 | 3.7589 | 3.7889 |
+-----------+-----------------+------------------+-----------------+------------------+


Table Currency
+----------+----------+--------+--------+---------------------+
| platID | currency | buy | sell | timestamp |
+----------+----------+--------+--------+---------------------+
| 2 | EUR | 4.1281 | 4.1561 | 2015-08-01 13:47:01 |
| 1 | USD | 3.7589 | 3.7889 | 2015-08-01 13:47:01 |
| 2 | USD | 3.7563 | 3.7843 | 2015-08-01 13:47:01 |
| 2 | GBP | 5.8732 | 5.9122 | 2015-08-01 13:47:01 |
| 1 | EUR | 4.1265 | 4.1565 | 2015-08-01 13:47:01 |
| 1 | GBP | 5.8734 | 5.9134 | 2015-08-01 13:47:01 |
| 2 | CHF | 3.8904 | 3.9249 | 2015-08-01 13:47:01 |
| 1 | CHF | 3.8928 | 3.9328 | 2015-08-01 13:47:01 |
| 1 | USD | 3.7589 | 3.7889 | 2015-08-01 13:46:02 |
| 1 | GBP | 5.8734 | 5.9134 | 2015-08-01 13:46:02 |
| 1 | EUR | 4.1265 | 4.1565 | 2015-08-01 13:46:02 |
| 1 | CHF | 3.8928 | 3.9328 | 2015-08-01 13:46:02 |
| 2 | USD | 3.7563 | 3.7843 | 2015-08-01 13:46:01 |
| 2 | EUR | 4.1281 | 4.1561 | 2015-08-01 13:46:01 |
| 2 | CHF | 3.8904 | 3.9249 | 2015-08-01 13:46:01 |
| 2 | GBP | 5.8732 | 5.9122 | 2015-08-01 13:46:01 |
+----------+----------+--------+--------+---------------------+

Thans in advance!

Options: ReplyQuote


Subject
Written By
Posted
Multiple selects from same table
August 03, 2015 02:37PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.