A car form (one million records)
A car ID device number, lane number, image path, car time
Field (GCID, SBBH CDBH, imgurl GCSJ)
Lane information table CDXX (one thousand records)
(ID SBBH CDBH) under the equipment number is the only one with multiple lane number
Note: the two tables did not establish foreign keys
Now need a period of time all lanes each lane to take a picture, there is no record image blank
Please everyone a great god show
SELECT DISTINCT SBBH, CDBH
The FROM GCJL
WHERE GCSJ & gt; 08:00:00=TO_DATE (' 2014-01-15 ', '- DD YYYY - MM HH24: MI: SS')
AND GCSJ & lt; 09:00:00=TO_DATE (' 2014-01-15 ', '- DD YYYY - MM HH24: MI: SS');
Now think only of to heavy equipment number and lane number but to other columns do not display for you after the great spirit show
Left lane information table join a car form only through SBBH and CDBH lane will be greater than the record of the information table
To everybody a great god directions for every great god give directions to everybody a great god directions for every great god show
CodePudding user response:
SELECT distinct CDXX SBBH, CDXX. CDBH
The FROM CDXX CDXX left join GXJL GCJL
On CDXX. SBBH=GCJL. SBBH AND CDXX. CDBH=GCJL. CDBH
WHERE JGSJ & gt; 08:00:00=TO_DATE (' 2014-01-15 ', '- DD YYYY - MM HH24: MI: SS')
AND JGSJ & lt; 08:00:01=TO_DATE (' 2014-01-15 ', '- DD YYYY - MM HH24: MI: SS')
You can't get my want image path to solve solution
CodePudding user response:
SELECT CDXX SBBH, CDXX. CDBH, Max (imgurl)
The FROM CDXX CDXX left join GXJL GCJL
On CDXX. SBBH=GCJL. SBBH AND CDXX. CDBH=GCJL. CDBH
WHERE JGSJ & gt; 08:00:00=TO_DATE (' 2014-01-15 ', '- DD YYYY - MM HH24: MI: SS')
AND JGSJ & lt; 08:00:01=TO_DATE (' 2014-01-15 ', '- DD YYYY - MM HH24: MI: SS')
Group by CDXX SBBH, CDXX. CDBH;
CodePudding user response:
Logic is a bit messy, look for 2 times just understandYou just to show SBBH CDBH, and then add any a picture record imgurl?
CodePudding user response: