SQL Split total only from options in another table

Viewed 30

This question will be mind-bending. Let's get started.
Let's say I have a total of $50 and the $50 dollars is split into rows in another table. EXAMPLE

Table 1
ID Total
--    -----
1      $50

Table 2
-------------
ID     Price
--     ------
1       $20
1       $10
1       $10
1        $5
1        $5 

BUT Table 2 can only accept these values from table 3

      Table 3
    -------------
    ID     Price
    --     ------
    1       $10
    2       $20
    3       $30
    4        $1
    5      $2.50

Question:

How can I tell SQL to recreate table 2 to either look like this

Table 2 - DESIRED OUTPUT
-------------
ID     Price
--     ------
1       $20
1       $10
1       $10
1       $10

OR

  Table 2 - DESIRED OUTPUT
    -------------
    ID     Price
    --     ------
    1       $20
    1       $10
    1       $10
    1       $2.50
    1       $2.50
    1       $2.50
    1       $2.50

OR

 Table 2 - DESIRED OUTPUT
        -------------
        ID     Price
        --     ------
        1       $20
        1       $10
        1       $10
        1       $2.50
        1       $2.50
        1       $1
        1       $1
        1       $1
        1       $1
        1       $1

OR

Table 2 - DESIRED OUTPUT
            -------------
            ID     Price
            --     ------
            1       $20
            1       $10
            1       $10
            1       $1
            1       $1
            1       $1
            1       $1
            1       $1
            1       $1
            1       $1
            1       $1
            1       $1
            1       $1

OR any variation based on Table 3.

0 Answers
Related