SQL Query to Retrieve Inverter Data Between Specific Dates
The given SQL query retrieves records from the tables "Inverter_History", "Equipment_Info", and "Equipment_Type" based on certain conditions. Here's a breakdown of the query:
-
The first two lines set the variables "@__startTime_1" and "@__endTime_2" with specific timestamp values.
-
The SELECT statement retrieves the following columns from the tables:
- RecordTime
- ThisPower
- ThisElectricityPrice
- TypeName from Equipment_Type
- EquipmentName from Equipment_Info
- EquipmentId (aliased as Id) from Equipment_Info
-
The query performs a LEFT JOIN between the tables "Inverter_History" and "Equipment_Info" using the EquipmentId column.
-
Another LEFT JOIN is performed between the result of the previous join and the "Equipment_Type" table using the EquipmentTypeId column.
-
The WHERE clause applies the following conditions:
- i.Deleted is not true
- e.EnterpriseId equals '1638003434462388224'
- e.IsEnable is true
- e.Deleted is false
- e0.IsEnable is true
- e0.Deleted is false
- e0.TypeName equals '逆变器' (Inverter in Chinese)
- i.RecordTime is between the specified start and end timestamps
Overall, the query retrieves records from the Inverter_History table along with additional information from the Equipment_Info and Equipment_Type tables, based on the specified conditions.
原文地址: https://www.cveoy.top/t/topic/pyJI 著作权归作者所有。请勿转载和采集!