0

I am having a table name tbl_details where it gives output as column name Memo No., Client Name, Stoneid, Status along with values given below. I tried many solutions from SF but none worked for me, so i posted here.

enter image description here

Question: I want to find number of Stoneid is Pending, Completed and Returned and if Total No. of Stones column is equal to No. Of Stones Completed then Final Status will be Completed. I am sharing the 4 Scenerios in below images

enter image description here

I am new to this. Any help will be appreciated.

convicted
  • 35
  • 7
  • @TheImpaler , I want the pivot table. I am not able to form query, I am very new. 1st image is table value, 2 one is the output I want from table, simple. thanks for you quick response. – convicted Aug 20 '20 at 15:44
  • 1
    Here you go: `select memo_no, client_name, count(*) as total_stones, sum(case when status = 'Completed' then 1 else 0 end) as completed, sum(case when status = 'Pending' then 1 else 0 end) as pending, sum(case when status = 'Return' then 1 else 0 end) as returned, case when sum(case when status = 'Pending' then 1 else 0 end) = 0 then 'Completed' else 'Pending' end as final_status from tbl_details group by memo_no, client_name` – The Impaler Aug 20 '20 at 15:45
  • @TheImpaler, Thank you very much, it was so easy. I highly appreciate your quick response. – convicted Aug 21 '20 at 07:18

0 Answers0