Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

SQL Syntax - response (4) by ulrich

$
0
0

It's like Dieter suggested
try 

replace view test_db _uli.v_test1
as
select a.col1,
       a.col2,
       a.col3,
       b.col4
from
(
select calendar_date as col1, 
       month_of_year as col2, 
       year_of_calendar as col3
from sys_calendar.calendar
) a
left join 
(
select calendar_date as col1, 
       year_of_calendar as col4
from sys_calendar.calendar
qualify row_number() over (partition by month_of_calendar order by calendar_date) = 1
) b
on a.col1 = b.col1
;

select * from test_db _uli.v_test1 
where col2 = 3 and col3 in ( 2012, 2013)
order by 1

 


Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>