473,386 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Aggregate Function Error ???

Am in the following cenario:

Table: tb_test
asset and Desc are of text type feilds.
Expand|Select|Wrap|Line Numbers
  1. ----------------------
  2. prt1 | prt2 | asset | Desc
  3. ----------------------
  4.  1      1      11      xxx
  5.  2      1      21      yyy
  6.  1      2      12      zzz
  7.  1      1      11      xxx
  8.  2      1      21      yyy
  9. ============================
  10.  
What i want to get (syntax):
Select asset and desc from table Order By asset

AM trying this sql query:
[code]
Select asset, desc from tb_test GROUP BY asset
[code/]

Am getting desc is not part of aggregate function, which am not sure why this error showing, i beleive it shouldnt. since always the values of the desc reveal same values for the corresponding asset value.

Any body can give a hint ??
Apr 6 '11 #1

✓ answered by Rabbit

Expand|Select|Wrap|Line Numbers
  1. Select asset, Max(desc) from tb_test GROUP BY asset

10 1963
VijaySofist
107 100+
Hi,

Actually Desc is a Keyword in SQL. If you want to to use the Query to Select that Column named desc, try the Code below

Expand|Select|Wrap|Line Numbers
  1. Select [asset], [desc] from tb_test GROUP BY asset
Regards
Vijay.R
Apr 6 '11 #2
Thanks Vijay , but i mentioned Desc just a shortcut to my Description field, sorry.

Its not the key word issue.
thanks any way
Apr 6 '11 #3
Rabbit
12,516 Expert Mod 8TB
Use a distinct clause instead of group by.
Apr 6 '11 #4
hey rabbit
but this will not solve , if later i need to get SUM of two feilds for each record and present it as total for each asset, thats why am using group by.
Apr 6 '11 #5
Rabbit
12,516 Expert Mod 8TB
Then you need to either group by desc as well or use an aggregate function on desc.
Apr 6 '11 #6
i tried :
Expand|Select|Wrap|Line Numbers
  1. Select asset, desc from tb_test GROUP BY asset order by asset 
same error
also tried
Expand|Select|Wrap|Line Numbers
  1. Select asset, desc from tb_test GROUP BY asset order by desc
same error.


up to my knowledge , if the value of the desk returned per asset are different than each other then it generates an error. while if they are equal , which is the case , error should not generate.
ie: for all asset 11 the desc is xxx
Apr 6 '11 #7
Rabbit
12,516 Expert Mod 8TB
You're ordering by desc? I said you need to group by desc. If you group by it, you may need to include an arbitrary aggregate field. Or you could use an aggregate function on desc and bypass the group by, even if technically you don't want to aggregate on it.
Apr 6 '11 #8
I tried all combinations in order and group through asset and desc ... if by lcuk to be true, but non broght up a result.

Can you type in what will be the statment with the use of an aggregate function.

First time use bypass.

As reports get more complex, sqls giving more headaches , i have a more complex sql st. i will post in onother thread , may be ill find who can help.
Apr 6 '11 #9
Rabbit
12,516 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. Select asset, Max(desc) from tb_test GROUP BY asset
Apr 6 '11 #10
Rabbit , it worked , great.... thaks alot .
Apr 6 '11 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Shannan Casteel via AccessMonster.com | last post by:
I have an invoice form with Parts and Labor as subforms. The parts section is based on a query that pulls data from 2 tables (tblParts & tblPartPerClaim) .. It has fields: ClaimID:...
1
by: Najib Abi Fadel | last post by:
Hi i have an ordered table of dates let's say: 1/1/2004 8/1/2004 15/1/2004 29/1/2004 5/2/2004 12/2/2004
1
by: R.A.M. | last post by:
Hello, I am learning SQL Server 2005. I have (correctly) written in .NET assembly DemoSQLServer with aggregate function AvgNoMinMax in class Demo and I have added assembly to database...
5
by: BillCo | last post by:
I just wasted a long time figuring out this and I figure if I post it might save someone some pain! Jet (DAO) will allow you to to use nested aggregate functions like building blocks, e.g.: ...
2
by: Ian825 | last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. My guess is that I need to dereference my...
3
by: ncsthbell | last post by:
I am pulling my hair out on this! Seems like it should be easy, I just can not get it to work like I want. I know I am doing something wrong, so I hope someone can be so kind to guide me!!! I...
3
by: cpanthro | last post by:
Hello, I'm using Access on XP and I am trying to count the number of cases in a Table via a query using two criteria. The criteria are being drawn from two different tables. I keep getting an...
7
by: kpfunf | last post by:
Getting the following error opening a report, cannot figure out the cause: "You tried to execute a query that does not include the specified expression 'RQ_FuelQuoteReportHistory.Vendor' as part...
4
by: denveromlp | last post by:
Hello, I've been getting the following error message in multiple queries, over and over again and I don't understand what it doesn't like. "You tried to execute a query that doesn't include the...
1
by: Stevestan1 | last post by:
I am getting the "cannot produce expression ..... as part of aggregate function" error everytime I try to run a query with this expression Pricing: IIf(! Is Not Null And ! <= !,"Pricing","None") ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.