Jump to content

Help with SQL query - Previously calculated in Excel


suprsnipes

Recommended Posts

Help with SQL query

I have a table with the following columns.

 

ID1

TYPE1

PRICE1

SIZE1

 

I need to put together a query that calculates the following in the one step...previously I was calculating this in Excel.

 

1. IF(AND(TYPE1='N', PREVIOUS_ID1='a', PRICE1>=PREVIOUS_PRICE1),THEN

INSERT INTO new column SUM(+SIZE1)

 

2. IF(AND(TYPE1='N', PREVIOUS_ID1='b', PRICE1<=PREVIOUS_PRICE1),THEN INSERT INTO new column SUM(-SIZE1)

 

The SIZE1 column is shown as a number, for example 002, 011, 001 etc. If the above 1. statement is true then insert into new column the sum of size1 as a plus, if 2. statement is true insert into new column the sum of size1 as a negative for further analysis.

Why not retain Excel for the business logic by using a PHP based calculation engine that replicates Excel functionality?

 

In saying that do you have any suggestions as to how I could go about this?

A little PHPExcel library listed in my signature would be one option. You can read/write Excel files directly from PHP, and it has a built-in calculation engine that replicates most of Excel's functions.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.