Here I have have a table
expenses
with columns
- id (PK)
- type_id (FK)
- amount
- date
- vehicle_id (FK)
In my jtable I want to show it like this 
I used this sql code the
SELECT vehicle_id,SUM(amount) FROM expenses GROUP BY type_id;
And I got output as
But I want it like previous image (the long one).. What can I do to this ?
Note
Here I used Sum for get multiple amount values.type_id used to denote various expenses type like diesel, oil, service..

sqltag to list of tags. About question: did you consider usingleft joins in your SQL query?