Hot answers tagged

3

It really depends on your main goal - if it should look 100% like your result in the question above then I am sorry the answer is no. If you want to get a result with the sum etc. yes there are ways round the union but you might not see the "Total" text. Here is one solution idea (with less data and columns as I could not extract it from your question). ...


2

Based on your comment this seems to be an ISO week number, but the logic is the same for any other numbering schema: take the year and convert it to the first day of the first week of this year, then add the (weeknumber -1) * 7 to get the starting day of the week and add 4 to get Friday. I don't know about DB2 syntax, but a quick check revealed that TRUNC ...


1

Sounds like you are not properly deallocating objects like Statement, ResultSet, etc., so your application is holding open statement handles in the database. This will eventually exhaust "CLI Packages" in the database, resulting in the SQL0805N error. The proper solution is to make sure that you close these as soon as you're done reading them. You may ...


1

Have you tried GROUPING SETS? Something like: SELECT CS_YEAR AS YEAR, CS_MNTH AS MONTH, CS_WK AS WEEK_NO, COALESCE(COST_CARRIER, 'Total') AS COST_CARRIER, COALESCE(COST_CARRIER_CD, 'Total') AS COST_CARRIER_CD, SUM(CS_WG_CST) AS WAGE_COST, SUM(CS_PART_CST) AS MATERIAL_COST, SUM(CS_DH_CST) AS ...



Only top voted, non community-wiki answers of a minimum length are eligible