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 2005 Forums
 Transact-SQL (2005)
 Simply Query Help Needed

Author  Topic 

bommer87
Starting Member

2 Posts

Posted - 2008-08-12 : 22:11:05
Table has these fields

ISBN
TITLE
PUBDATE
PUBID
COST
RETAIL
CATEGORY
----------

Here is sample data

9247381001
HOW TO MANAGE THE MANAGER
09-MAY-99
1
15.4
31.95
BUSINESS

----------------------------
SQL> select category, TO_CHAR(sum(retail),'$9999.00') as "Total Retail", TO_CHAR(AVG(retail),'$9999.00') as "Average Retail" from books group by category;

CATEGORY Total Retail Average Retail
------------ --------- ---------
COMPUTER $211.40 $52.85
COOKING $48.70 $24.35
CHILDREN $68.90 $34.45
LITERATURE $39.95 $39.95
BUSINESS $31.95 $31.95
FITNESS $30.95 $30.95
FAMILY LIFE $111.95 $55.98
SELF HELP $29.95 $29.95

8 rows selected.
--------------
I need to show only those with Total Retail > 40 cannot get that to work.

dexter.knudson
Constraint Violating Yak Guru

260 Posts

Posted - 2008-08-12 : 23:02:28
This looks like ORACLE SQL, this is a Microsoft SQL Server forum.
However, Add-
HAVING "Total Retail" > 40
If this doesn't work, you may need-
TO_CHAR(sum(retail),'$9999.00')
Go to Top of Page

bommer87
Starting Member

2 Posts

Posted - 2008-08-12 : 23:22:14
Yes this is Oracle SQL didnt mean to post in wrong forum. The good news is it worked with HAVING sum(retail) > 40. Thanks for the help.
Go to Top of Page
   

- Advertisement -