Skip to content

Tag: pivot

Convert rows to columns using PIVOT

I have a table named AmountList in SQL Server : where Primary key is ” UniqueCol1, UniqueCol2, AmountID ” and on the basis of AmountID I want to Pivot the results as: I am facing the challenge using Pivot because only Aggregate functions can be used but I need actual values of the fields. UPDATE: …

Compare two values in a row

select event_slots.id as event_slot_id, u.first_name, u.id AS user_id, sum(case when next_round = 1 then 1 else 0 end) AS yes, sum(case when next_round = 2 then 1 else 0 end) AS no from event_slots …

How to count multiple columns in SQL (Oracle) with criteria?

I’m working on SMS-Gateway that holds multiple charged SMS-services with different numbers, each SMS sent to the customer has 4 status as below (forwarded, delivered, expired,delivery failed) Now I have the below first_table for the charging-system with the below details (TABLE-A) and below (TABLE-B) wh…