SQl Statement

Hello Folk,
I am new to SQL and I am trying to Join two table date. One date is organization date and another date I have in data. I want to align both data like lookup.
This is my current statement:

SELECT * FROM SC_ODS.TAR_MOVE_ST t10

WHERE CARRIER_ID IN
('PINNACL_60', 'PINNACL_28','PINNACL_61','PINNACL_SCA','PINNACL_OW')

JOIN ba_tmextra.cal_dt cal on trunc(tl0.START_DATE)

AND

START_DATE BETWEEN to_DATE ('01-OCT-2022' ,'DD-MM-YYYY') AND tO_DATE ('28-FEB-2023', 'DD-MM-YYYY')
Can someone tell me how can I correct so that both date marge or lookup?

Thanks

hi

this is a Microsoft SQL Server Forum

your code does not look correct ? maybe copy paste issue

SELECT 
    * 
FROM 
    SC_ODS.TAR_MOVE_ST t10
JOIN 
   ba_tmextra.cal_dt cal 
ON 
   trunc(tl0.START_DATE) ????? == something is missing here    
WHERE 
     CARRIER_ID IN
                ( 'PINNACL_60'
				    ,'PINNACL_28'
				    ,'PINNACL_61'
				    ,'PINNACL_SCA'
				    ,'PINNACL_OW')
	          AND 
     START_DATE   BETWEEN 
	    to_DATE ('01-OCT-2022' ,'DD-MM-YYYY') 
		     AND 
	    tO_DATE ('28-FEB-2023', 'DD-MM-YYYY' )		

   
Typically it looks like this 

ON table1.colA = table2.ColB

SELECT * FROM SC_ODS.TAR_MOVE_ST T1

INNER JOIN ba_tmextra.cal_dt T2
ON
T1.START_DATE = T2.CAL_DT

WHERE CARRIER_ID IN
('PINNACL_60', 'PINNACL_28','PINNACL_61','PINNACL_SCA','PINNACL_OW')

AND

START_DATE BETWEEN to_DATE ('01-OCT-2022' ,'DD-MM-YYYY') AND tO_DATE ('28-FEB-2023', 'DD-MM-YYYY')

I created this one it is working but I am getting less data set.

I found solution.

Nice

Njoy

happened to me 1 BILLION times

:+1: :grinning:

1 Like

Two way street here, @Amjad1002 . Please post your solution. Thanks.