zoukankan      html  css  js  c++  java
  • SQL语句

    1.获取不同设备的最后一条记录 SQL消费表中查找所有用户最后一条消费记录

     select a.* from GPRS.DBO.View_GPRS

    a where not exists(select 1 from GPRS.DBO.View_GPRS where 设备号 = a.设备号 and 采集时间 > a.采集时间 )

    优化:

    select a.* from [TYN].[dbo].[View_SolarEnergy] a
    where not exists(select 1 from [TYN].[dbo].[View_SolarEnergy] b
    where b.设备编号 = a.设备编号 and b.数据采集时间 > a.数据采集时间)

    2.获取当天时间最新的20条数据,并且各个字段值都不为空

    string cmd = "select TOP 20 温度,电池电压,电池电量,采集时间 from View_GPRS where 温度 is not null and 电池电压 is not null and 电池电量 is not null and 采集时间>'" + currentDateTime + "' and 设备号 ='" + IMEI + "' order by 采集时间 desc";

    select TOP 20 温度,电池电压,电池电量,采集时间 from GPRS.dbo.View_GPRS
    where 温度 is not null and 电池电压 is not null and 电池电量 is not null and 采集时间>'2019/10/17' and 设备号 ='868221048182987' order by 采集时间 desc

  • 相关阅读:
    C#拼音转换,将简体中文转换成拼音
    C#发送邮件
    textBox只能输入汉字
    IOS中UIScrollView的详细使用
    AngularJs学习教程
    IOS-简单计时器的使用
    IOS-多视图控制器之间的切换
    IOS播放音乐和音效
    Nodejs_day04
    Nodejs_day03
  • 原文地址:https://www.cnblogs.com/youzi-xuchongyou/p/11686897.html
Copyright © 2011-2022 走看看