View Joining two fields of a table

Tools & Utilities

View Joining two fields of a table

Hi All, 

I have a table with Calendar Month(ex.10) & Year(ex.2014) as two different fields ( Month Number & Year).

But i will have to create a view on this table where user can just pass one value ex. 201401 where 2014 has to be passed to year column and 01 to month column of the table and fetch the respective record.

Can i have a sample code/script to create this kind of view to address this requirment?

Thanks

Karthik

3 REPLIES

Re: View Joining two fields of a table

To Add, these two fields are or data type Integer.

Junior Contributor

Re: View Joining two fields of a table

yearmonth is usually calculated using yearcol * 100 + monthcol as yearmonth

But why can't you simply use two conditions? WHERE yearcol = 2014 and monthcol = 10 will allow the optmizer to apply existing statistics?

Re: View Joining two fields of a table

Hi Dieter,

Thank you for reply.

Acutually the user has an another table which has these two fields as one column. They are not comfortable in joining one table with mergeed values and one table column with splited month & year.