loader gif

Complex query on SQL

I need help 🙂

What we have:

1. The table A with next columns:

      asset – VARCHAR
      decimals – INT
      description – VARCHAR

2. The table B with next columns:

      asset – VARCHAR
      price – VARCHAR
      amount – VARCHAR
      order – VARCHAR (unique)
      type – VARCHAR (may be ‘ask’ or ‘bid’ value only)

What I need to get:

For any asset ID I need next information:

      asset
      decimals
      description
      min price from table B if type = ask and the same asset
      sum for min price
      max price from table B if type = bid and the same asset
      sum for max price

Right now I have three different sql query for this result. I tried to create some view. It didn’t work for me.

Who can help me? 🙂

P.S. Don’t ask me about VARCHAR ))
P.P.S. MySQL

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.