Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Adding up upgrades

Author  Topic 

Movember
Starting Member

12 Posts

Posted - 2009-12-02 : 21:49:29
I have a problem with trying to add up totals of a package that has an upgrade.

For example - we have packages, and they can get upgrades. i.e.

Package 1 Level 1 $100 - with upgrade - $150
Package 1 Level 2 $200 - with upgrade - $275
Package 2 Level 1 $300 - with upgrade - $395
Package 2 Level 2 $400 - with upgrade - etc...

How do I report what is base price and what is upgrade?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-02 : 21:50:31
Could you show us your table structure and how that data is separated into columns?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

Movember
Starting Member

12 Posts

Posted - 2009-12-02 : 22:12:20
This is the table in question.

TransactionID
TransactionDate
MemberID
OrganisationID
SubscriptionID
LinkID
Title
Detail
Amount

The way I am separating the upgrades is via the title i.e.

sum(CASE WHEN Title like '%upgrade1%' THEN 50 ELSE '0' END) AS Upgrade1,
sum(CASE WHEN Title like '%upgrade2%' THEN 50 ELSE '0' END) AS Upgrade2,
sum(amount) as 'total'

but I need the leftover package total to all sum in one field.

Does this make sense?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-03 : 00:15:18
So that entire string is stored in the Title column? For instance "Package 1 Level 1 $100 - with upgrade - $150" is in one column? If that's the case, you need to change your database design so that you do not need to write complex queries.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

Movember
Starting Member

12 Posts

Posted - 2009-12-03 : 00:55:10
Can't change the database design, working of a third party application.
Go to Top of Page
   

- Advertisement -