troubleshooting Question

SQL query trying to sum one fields with three different criteria

Avatar of woodje
woodjeFlag for United States of America asked on
Oracle DatabaseMicrosoft SQL Server 2005
15 Comments1 Solution814 ViewsLast Modified:
I have a table that I am trying to pull the phone # and then sum usage for three different date ranges. However I have a sytex problem and for the life of me I can not find it. Please let me know your thoughts. I have included the SQL code below. Thanks.
SELECT
 
Phone#,
(select 
	SUM(D_USG_B)
	where D_USG_DT between 1080408 and 1080505) as Prior,
(select 
	SUM(D_USG_B) 
	where D_USG_DT between 1080506 and 1080602) as During,
(select 
	SUM(D_USG_B)
	where D_USG_DT between 1080603 and 1080701) as Post	
 
 
FROM X_USAGE_V
 
WHERE Phone# = '9995551212'
 
 
Group by
	1
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 15 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros