Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Expression Question 1

Status
Not open for further replies.

brainmetz

Technical User
Feb 12, 2003
34
US
Everytime I run the following code:

SELECT (All_Urls.[Computer Name]), (-1 * (All_Urls.[URL Address] LIKE '*att*') * Sum (All_Urls.[SumOfTotal Time])) AS [SumOfSumOfTotal Time]
FROM [All_Urls]
GROUP BY (All_Urls.[Computer Name]);

I recieve an error stating:

You tried to execute a query that does not include the specified expression '(-1 * (All_Urls.[URL Address] LIKE '*att*') * Sum (All_Urls.[SumOfTotal Time])' as part of an aggregate function.

Can anyone please help me decifer this message.

Thanks in advance.
 
I think this might solve your problem:

SELECT (All_Urls.[Computer Name]), Sum(-1 * (All_Urls.[URL Address] LIKE '*att*') * Sum (All_Urls.[SumOfTotal Time])) AS [SumOfSumOfTotal Time]
FROM [All_Urls]
GROUP BY (All_Urls.[Computer Name]);

OR

SELECT (All_Urls.[Computer Name]), Sum((-1 * (All_Urls.[URL Address] LIKE '*att*') * All_Urls.[SumOfTotal Time])) AS [SumOfSumOfTotal Time]
FROM [All_Urls]
GROUP BY (All_Urls.[Computer Name]);

OR (but probably not what you want)

SELECT (All_Urls.[Computer Name]), (-1 * (All_Urls.[URL Address] LIKE '*att*') * Sum (All_Urls.[SumOfTotal Time])) AS [SumOfSumOfTotal Time]
FROM [All_Urls]
GROUP BY (All_Urls.[Computer Name]),(-1 * (All_Urls.[URL Address] LIKE '*att*') * Sum (All_Urls.[SumOfTotal Time]));

Depending on what you're trying to do.

 
Thanks your secondone worked...i just had to change my data type from Memo to text with 255 characters.

The first one returned the same error as I had before.

Thanks alot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top