求好心人解答
我用的是Mysql資料庫
記錄樣式 mac,date
我想查詢出條件(mac相同,date時間相差為x)的資料條數,請問該怎么辦
例如x=2
uj5u.com熱心網友回復:
同表關聯笛卡爾積,mac相等并且日期相差x天uj5u.com熱心網友回復:
if not object_id(N'Tempdb..#tab') is null
drop table #tab
Go
Create table #tab([id] int,[je] int,[rq] Date,[xh] int)
Insert #tab
select 1003019,100,'2019-01-07',1 union all
select 1003023,100,'2019-01-05',2 union all
select 1007152,100,'2019-01-09',3 union all
select 1007152,100,'2019-01-04',4 union all
select 1007152,100,'2019-05-05',5 union all
select 1007152,100,'2019-02-07',6 union all
select 1007152,100,'2019-01-06',7
GO
--測驗資料結束、
select * from #tab
go
select * from #tab where je='100' and rq = dateadd(day,-2,'2019-01-07')
id je rq xh
1003023 100 2019-01-05 2
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/134983.html
標籤:疑難問題
上一篇:關于dispatcherservlet對jsp和thymeleaf的疑問?
下一篇:編程的本質
