let table name "box" the box will have
1. pen
2. pencil
3. eraser
4. sharpener
5. scale
but may SQL table looks like this,
s no.___ item____ quantity
1 _____ pen_____ 2
2 ____ pencil____ 3
3____ eraser____ 5
i need a query, which gives me the following output
item______ quantity
pen ______ 2
pencil ____ 3
eraser ____ 5
sharpener__ 0
scale ____ 0
This is the query i am using right now
select CASE disease_confirmed when 'Forward to EMMINENT Cardiologist' then 'Repeat ECG Within 10 Minutes' when 'Yes' then 'Yes' when 'No' then 'No' when 'Re-take ECG' then 'Re-take ECG' when 'Reassign to 1 Cardiologist' then 'Reassign to 1 Cardiologist' when 'Reassign to 2 Cardiologists' then 'Reassign to 2 Cardiologists' when 'Reassign to 3 Cardiologists' then 'Reassign to 3 Cardiologists'
END AS disease_confirmed,
count(disease_confirmed) from immi_referral_tb where created_date>= '2015-11-01 00:00'::timestamp AND created_date<= '2015-11-30 23:59'::timestamp group by disease_confirmed union all SELECT 'Total',count(disease_confirmed) from immi_referral_tb where created_date>= '2015-11-01 00:00'::timestamp AND created_date<= '2015-11-30 23:59'::timestamp;
output:
so i need the following values under "disease confirmed column" Re-take ECG Yes Reassign to 3 Cardiologists Repeat ECG Reassign to 1 Cardiologist No Reassign to 2 Cardiologists
but according to my query i have 1 month time period, so some of the above values are not present in the column for that time period.
so, need those all values in the output like null '0' if there are not present in the column.