SQLite Forum

Help with a query
Login
Thanks for this, as I suspected, the basic query is a simple one which I have used before.

In my response to Ryan, I have explained in more detail what I am looking for, need to go this process due to my lack of knowledge so hope you can bear with me.


I have expanded on the example you have given. table DDL is in the response to Ryan.

SELECT pollDate, 
       sum(importKwh)/2.0 as PeakImport, 
       (sum(importCost) * sum(importKwh) / 2.0) as PeakCost,
       sum(importKwh) as OffPeak, 

       -- need to get this info, don't know if it can be done in the 1st SELECT 
       -- don't now if it can be done here or needs to be done somewhere else, have tried with errors

              (SELECT (sum(importedKwh) * sum(importCost)) as OffPeakCost, 
              WHERE interval BETWEEN 22 AND 24 AND BETWEEN 1 AND 14 
              FROM Readings),

       -- continue as part of the 1st SELECT       
              sum(reversePart) as solar

FROM Readings
WHERE interval BETWEEN 14 AND 22
GROUP BY pollDate

After this, I will probably need to alter any resulting sql to include additional parts that need to be done based on the expected deficiency in describing further what is needed to get the outcome I need.

Thanks Ryan,