ryanneves_1 Posted February 20, 2019 Share Posted February 20, 2019 I have a SQL query that pulls a list like this based off the data returned from the query.Lane Run 10 210 310 6(new page on lane change)11 211 311 5I would like it to insert a blank line when one is missing like below, anyone have ideas on doing that.Lane Run 10 210 310 6(new page on lane change)11 211 311 5 Link to comment Share on other sites More sharing options...
Alex42 Posted February 21, 2019 Share Posted February 21, 2019 This is SQL work. I suggest you generate the missing data and add a flag that will tell you if the row is generated or not(ex: O=original G=generated). Your result data set would look likeLane Run Flag10 2 O10 3 O10 4 G10 5 G10 6 O(new page on lane change)The flag will be the conditional that will display or not the values in the line Link to comment Share on other sites More sharing options...
ryanneves_1 Posted March 8, 2019 Author Share Posted March 8, 2019 This is kinda what I came up with but I don't know how to make it work with JasperReports.My query would be something like this:WITH CTE AS (SELECT lane_number, MIN(sequence) minSeq, MAX(sequence) maxSeqfrom v_sampleGROUP BY lane_numberUNION ALLSELECT lane_number, minSeq + 1, maxSeqfrom CTEWHERE minSeq+1 <= maxSeq)Select t2.*, t1.lane_number, t1.minSeq as sequence from CTE t1 left join v_sample t2 on t1.lane_number = t2.lane_number and t1.minSeq = t2.sequenceorder by t1.lane_number, t1.minSeq; But it would have my original one nested in it for the VIEW, but I don't see Jaspersoft supporting this in Reports.create view v_sample as (SELECT products.client_id, clients.name AS client_name, cars.vin, cars.make, cars.model, cars.style, cars.has_title, cars.general_description, cars.custom_description, cars.mileage, cars.'year', cars.ext_paint, cars.int_color, cars.manheim_submitted_on, products.stock_number, products.intake_date, manheim_auction_lanes.lane_number, manheim_auction_listings.sequence, product_titles.status AS title_status, manheim_auction_listings.gross_sale_price, product_purchases.sale_fee AS sales_fee, products.asking_price, products.asking_price_condition, manheim_auctions.auction_date, manheim_auctions.auction_number, manheim_auction_listings.created_at, manheim_auction_listings.updated_at, product_purchases.total_spent, users.username AS buyer_username, product_statuses.id AS product_status, product_statuses.description AS status_description, product_purchases.purchase_price, ( SELECT Count(*) FROM manheim_auction_listings AS listings_sub WHERE listings_sub.car_id = manheim_auction_listings.car_id AND listings_sub.id <> manheim_auction_listings.id) AS previous_auction_countFROM manheim_auction_listings JOIN cars ON cars.id = manheim_auction_listings.car_id JOIN products ON cars.product_id = products.id JOIN product_purchases ON current_product_purchase_id = product_purchases.id JOIN users ON product_purchases.buyer_id = users.id JOIN manheim_auctions ON manheim_auctions.id = manheim_auction_listings.manheim_auction_id AND manheim_auctions.auction_date = $p{auctiondate} JOIN manheim_auction_lanes ON manheim_auction_lanes.id = manheim_auction_listings.manheim_auction_lane_id JOIN product_categories ON products.product_category_id = product_categories.id AND product_categories.consigned_inventory=0 JOIN clients ON clients.id = products.client_id AND clients.id LIKE $p{loggedinuserattribute_clientid} LEFT JOIN product_titles ON product_titles.id = product_purchases.product_title_id JOIN product_statuses ON product_statuses.id = products.product_status_id ORDER BY manheim_auction_lanes.lane_number DESC, manheim_auction_listings.sequence DESC )go 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