ritesh.verma Posted July 4, 2017 Share Posted July 4, 2017 I have a very specific question. I hope someone can help me. My query needs to prompt for "TYPE"(see below column) and "start date" and "end date" from user, based on user input the query would run on source data to generate output as outlined below. My below example assumes the input value are TYPE: ID Start Date: 31DEC2016 End Date: 30 Jun 2017 Source tables: EMPDETAILSextended Staff number Date TYPE 1 25JAN2017 ID 1 30JAN2017 ID 1 04JUN2017 ID 2 01JAN2017 ID 2 01FEB2017 ID 2 28Mar2017 ID EMPDETAILS Staff number InitialDate 1 01JAN2017 2 01FEB2017 Output (see the columns for month are generated dynamically) StaffNumber InitialDate JAN17 FEB17 MAR17 APR17 MAY17 JUN17 1 01JAN2017 30JAN17 04JUN17 2 01FEB2017 01JAN17 01FEB17 28mar17 I am comfortable in getting this data but I am not sure how to output all this to dynamically create column name with the header as that specific month. I am using Oracle12C. I dont expect you to write the whole query for me but I am unable to figure out the approach and hence failing to formulate a working query? Link to comment Share on other sites More sharing options...
mlopez_1 Posted July 5, 2017 Share Posted July 5, 2017 With a crosstab.Mariano Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now