当前位置:网站首页>查询sql
查询sql
2022-06-09 20:01:00 【ps酷教程】
<select id="selectDeviceDataRecordByDeviceId" resultType="com.anbao.ambientMonitor.data.dto.device.DeviceDataValueDTO">
SELECT
pps.name AS propertyName,
ddr.property_value,
pps.unit,pps.params,pps.data_type
FROM
product_properties pps
LEFT JOIN device d ON d.product_id = pps.product_id
LEFT JOIN (
SELECT
a.product_property_id,
MAX(a.id) id
FROM
device_data_record a
WHERE
a.device_code = #{deviceCode}
GROUP BY
a.product_property_id
) temp ON pps.id = temp.product_property_id
LEFT JOIN device_data_record ddr ON ddr.id = temp.id
WHERE
pps.function_type = 1
AND pps.status = 1
AND pps.is_del = 0
AND d.device_code = #{deviceCode}
ORDER BY
pps.sort_value DESC
</select>
<select id="selectDataListByDeviceCodeAndRegionId" resultType="com.anbao.ambientMonitor.data.dto.region.DeviceDataRecordDTO">
SELECT
ddr.product_property_id,
d.device_code,
ddr.create_time,
ddr.unit,
ddr.property_value,
pps.name AS propertyName,
pps.data_type,
pps.params,
pps.identifier
FROM
device_data_record ddr
RIGHT JOIN (
SELECT
a.product_property_id,
MAX(a.id) id
FROM
device_data_record a
RIGHT JOIN ( SELECT
pps.id
FROM
device d
LEFT JOIN product_properties pps ON pps.product_id = d.product_id
WHERE
d.region_id = #{regionId}
AND d.is_del = 0 ) pp_temp on pp_temp.id = a.product_property_id
WHERE
a.region_id = #{regionId}
GROUP BY
a.product_property_id
) temp ON ddr.id = temp.id
RIGHT JOIN product_properties pps ON pps.id = temp.product_property_id
RIGHT JOIN device d ON pps.product_id = d.product_id
WHERE
d.region_id = #{regionId}
AND d.is_del = 0
AND pps.important_flag = 1
AND pps.metering_properties_flag = 1
AND pps.status = 1
AND pps.is_del = 0
ORDER BY pps.sort_value DESC
</select>
<select id="selectDataListByDeviceCode" resultType="com.anbao.ambientMonitor.data.dto.region.DeviceDataRecordDTO">
SELECT
ddr.product_property_id,
d.device_code,
ddr.create_time,
pps.unit,
ddr.property_value,
pps.name AS propertyName,
pps.data_type,
pps.params,
pps.identifier,
pps.rw_flag,
pps.identifier,
mrp.name AS positionName,
mr.region_name
FROM
device_data_record ddr
RIGHT JOIN (
SELECT
a.product_property_id,
MAX(a.id) id
FROM
device_data_record a
RIGHT JOIN ( SELECT
pps.id
FROM
device d
LEFT JOIN product_properties pps ON pps.product_id = d.product_id
WHERE
d.device_code = #{deviceCode}
AND d.is_del = 0 ) pp_temp on pp_temp.id = a.product_property_id
WHERE
a.device_code = #{deviceCode}
GROUP BY
a.product_property_id
) temp ON ddr.id = temp.id
RIGHT JOIN product_properties pps ON pps.id = temp.product_property_id
LEFT JOIN device d ON d.product_id = pps.product_id
Left JOIN region_position_device_mapping rpdm ON rpdm.device_id = d.id
Left JOIN merchant_region_position mrp ON mrp.id = rpdm.region_position_id
LEFT JOIN merchant_region mr ON mr.id = d.region_id
WHERE
d.device_code = #{deviceCode}
AND d.is_del = 0
AND pps.important_flag = 1
AND pps.metering_properties_flag = 1
AND pps.status = 1
AND pps.is_del = 0
ORDER BY pps.sort_value DESC
</select>
边栏推荐
- Leetcode 1984. 学生分数的最小差值(可以,已解决)
- The crayfish left out by the young people has only a life of losing money?
- Resolving the disorder of JSON parsing by fastjson
- Unity upgrade project to URP
- 驱动开发—基础
- 2022年GDCPC广东省大学生程序设计竞赛题解
- 用原生js实现退出全屏
- SMART PLC多次调用同一个子程序(FC)
- Taiwan once again strictly investigated the poaching of mainland enterprises: more than 100 people were dispatched, 10 enterprises were investigated, and nearly 70 people were interviewed!
- 种一棵树最好的时间是十年前,其次便是现在(C语言选择和循环训练题目)
猜你喜欢
随机推荐
【数据库数据恢复】SQL Server数据库数据恢复案例
开盘大涨近72%,国产CMP设备龙头华海清科登陆科创板
面试字节测开岗失败后,被面试官在朋友圈吐槽了......(心累)
台湾再度严查陆企挖角:出动百余人次,10家企业被查,约谈近70人次!
Win7 64 bit ultimate installation office2003 prompt: "error 1919, error occurred when configuring ODBC data source MS Access database ODEC error"
isArray()判断对象是否为数组
STM32内存知识
mysql数据类型
Isarray() judge whether the object is an array
Mobile application testing (6) - App Testing Technology (4)
Fastjson解析JSON时乱序解决
Aspx datatable row column interchange
欧盟要求所有手机平板采用USB-C接口!苹果将被迫放弃Lightning接口
20XX年全國職業院校技能大賽高職組“信息安全管理與評估”賽項任務書
ASPX DataTable 行列互换
Babbitt | metauniverse daily must read: Citibank reported that the metauniverse economy represents $13 trillion in income opportunities, and there are five identified early investment opportunities
2022年GDCPC广东省大学生程序设计竞赛题解
此虚拟机的处理器所支持的功能不同于保存虚拟机状态的虚拟机的处理器所支持的功能
Numbers that occur only once (XOR, hash table)
95後大廠程序員删庫被判刑9個月









