| 131 | === Customising Queries === |
| 132 | |
| 133 | To show the remaining hours column in your SQL queries, you need to join the ticket table with the ticket_custom table, which contains the custom fields: |
| 134 | {{{ |
| 135 | SELECT |
| 136 | ... # normal SELECT statement |
| 137 | id AS ticket, |
| 138 | ifnull(tc.value,'') as Hrs, # adds the value of estimatedhours in a column called Hrs, using '' if it doesn't exist. |
| 139 | FROM ticket t |
| 140 | LEFT JOIN ... # other LEFT JOIN statements (in the default Trac queries) can be left in place |
| 141 | LEFT JOIN ticket_custom tc ON tc.ticket = t.id and tc.name = 'estimatedhours' |
| 142 | ... |
| 143 | }}} |
| 144 | * You could change Hrs to 'Remaining Hours' to modify the column name. |
| 145 | * You could change {{{''}}} to '0' to show 0 hours for tickets that don't have a corresponding estimatedhours field. |
| 146 | * Tickets may have an estimated hours field that is empty, in which case you may still see "blank" |
| 147 | |