dimanche 22 février 2015

FACT table loading


I have the below table structure :


Ticket# Tckt_type Amount Acct Num 1 abc 10 1001 1 def 20 1002


So, for the same ticket number, there MAY be two different ticket types and different amounts.


CASE 1: If a particular ticket has both abc & def, then I need the below result (abc data with the sum of amount of both abc & def)


Ticket# Tckt_type Amount Acct Num 1 abc 30 1001


CASE 2:


If a particular ticket has only abc, then I need the details of abc record to be displayed


CASE 3: If a particular ticket has only def, then I need the details of def record to be displayed


CASE 4 : If a particular tickets has any other type other than abc & def, then the sum of the amounts of all those tickets should be displayed as "MISC amount" along with the ticket number of the record.


I need to load this data into a FACT table.


Could you please help me in writing a SQL query for the above requirement ? Please Help !!!





Aucun commentaire:

Enregistrer un commentaire