473,785 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help in group by query

26 New Member
Hi,

Please help me in the following query.

SELECT
a.bcast_id ,
a.bcast_file_nm ,
a.clickthru_url _cd ,
a.list_id ,
a.prs_id ,
a.resp_cd ,
a.run_seq ,
COUNT(a.resp_cd ) ,
c.src_grp_cd ,
b.site_cd
FROM
gca_cbx_respons e_test a ,
gca_program_run _hist b ,
campaign_master c
WHERE
a.list_id=b.lis t_id
AND
a.run_seq=b.cam paign_run_seq
AND
b.campaign_cd=c .campaign_cd
GROUP BY
a.bcast_id ,
a.bcast_file_nm ,
a.clickthru_url _cd ,
a.list_id ,
a.prs_id ,
a.resp_cd ,
a.run_seq ,
c.src_grp_cd ,
b.site_cd
HAVING
a.resp_ts
BETWEEN
to_date('04-AUG-2005 00:01:32','DD-MON-YYYY HH24:MI:SS')
AND
to_date('04-AUG-2005 00:01:32','DD-MON-YYYY HH24:MI:SS');

But the following group by query is throwing error that a.resp_ts is not a group by function.

But i don't want to add a.resp_ts in group by clause.

Please help me in this query.

Thanks,
Dilip
Jul 5 '07 #1
2 1439
madnanalim
1 New Member
Hi.
Plz check the following Query
SELECT
a.bcast_id ,
a.bcast_file_nm ,
a.clickthru_url _cd ,
a.list_id ,
a.prs_id ,
a.resp_cd ,
a.run_seq ,
COUNT(a.resp_cd ) ,
c.src_grp_cd ,
b.site_cd
FROM
gca_cbx_respons e_test a ,
gca_program_run _hist b ,
campaign_master c
WHERE
a.list_id=b.lis t_id
AND
a.run_seq=b.cam paign_run_seq
AND
b.campaign_cd=c .campaign_cd
And a.resp_ts Between to_date('04-AUG-2005 00:01:32','DD-MON-YYYY HH24:MI:SS')
AND to_date('04-AUG-2005 00:01:32','DD-MON-YYYY HH24:MI:SS')
GROUP BY
a.bcast_id ,
a.bcast_file_nm ,
a.clickthru_url _cd ,
a.list_id ,
a.prs_id ,
a.resp_cd ,
a.run_seq ,
c.src_grp_cd ,
b.site_cd ;
Jul 5 '07 #2
rnsahu
2 New Member
Hi.
Plz check the following Query
SELECT
a.bcast_id ,
a.bcast_file_nm ,
a.clickthru_url _cd ,
a.list_id ,
a.prs_id ,
a.resp_cd ,
a.run_seq ,
COUNT(a.resp_cd ) ,
c.src_grp_cd ,
b.site_cd
FROM
gca_cbx_respons e_test a ,
gca_program_run _hist b ,
campaign_master c
WHERE
a.list_id=b.lis t_id
AND
a.run_seq=b.cam paign_run_seq
AND
b.campaign_cd=c .campaign_cd
And a.resp_ts Between to_date('04-AUG-2005 00:01:32','DD-MON-YYYY HH24:MI:SS')
AND to_date('04-AUG-2005 00:01:32','DD-MON-YYYY HH24:MI:SS')
GROUP BY
a.bcast_id ,
a.bcast_file_nm ,
a.clickthru_url _cd ,
a.list_id ,
a.prs_id ,
a.resp_cd ,
a.run_seq ,
c.src_grp_cd ,
b.site_cd ;


see here we have to remember 1 thing, "having clause" logic is related to the result of group functions,as opposed to columns and expressions for individual rows.
Jul 5 '07 #3

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

Similar topics

4
10237
by: Surendra | last post by:
I have this query that I need to use in an Update statement to populate a field in the table by the value of Sq ---------------------------------------------------------------------------- Inline View Query: Select Sq from ( Select substr(to_date(End_Date,"DD-MON-YYYY"),4), End_Date, Rank() Over (Partition by substr(to_date(End_Date,"DD-MON-YYYY"),4) Order by End_Date) As Sq
9
3137
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use SUBSTRING(ProductName, 1, CHARINDEX('(', ProductName)-2). I can get this result, but I had to use several views (totally inefficient). I think this can be done in one efficient/fast query, but I can't think of one. In the case that one query is not...
17
1952
by: the other john | last post by:
This should be fairly basic but I can't think of how to do this and I'm running out of time! I am developing a picture gallery and I can't figure out how to select "one" picture from each gallery. My DB is configured like this... tbl_pictures this contains all pictures in the picture gallery. tbl_pictures_galleries
28
3307
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical make-believe challenge in order to avoid confusing the issue further. Suppose I was hosting a dinner and I wanted to invite exactly 12 guests from my neighborhood. I'm really picky about that... I have 12 chairs besides my own, and I want them all...
4
2659
by: Orion | last post by:
Hi, This is kind of last minute, I have a day and a half left to figure this out. I'm working on a project using ms-sqlserver. We are creating a ticket sales system, as part of the system, I need to be able to do a search for specific tickets withing price ranges, different locations within the theaters, etc. etc. My problem is in the search one of the criteria is to search for a group of seats together. For example let's say...
2
2344
by: Steve | last post by:
Access 97. I have a form where there is an option group with two buttons, and a combo box. The combo box Row Source is a query. The option group has two options a) include a subset of the query where all records with the field OPEN set to Yes, or return all records in the query (OPEN = Yes or No). If I "manually" set the criteria to 1 (yes) or 1 Or 2, I get the correct records returned. However, I want to use the option group
1
3198
by: James | last post by:
Access 2003, trying to count the number of records that meet a criteria. According to Help: "In the Database window, click Queries under Objects, and then click New on the database window toolbar. Add the table, view, or function you want to summarize in the Diagram pane. " OK, that's easy.....but then..... "Right-click the background of the Diagram pane, then choose Group By
0
2262
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional assistance. I say additional because I've already had help which is greatly appreciated. I do try to take the time and understand the provided script in hopes on not having to trouble others on those. But here it goes...
47
2887
by: Jo | last post by:
Hi there, I'm Jo and it's the first time I've posted here. I'm in process of creating a database at work and have come a little unstuck.....I'm a bit of a novice and wondered if anyone could help. I work in a library and send out dual language books to babies of dual or other nationality. The db is to be used for logging a range of book titles and numbers ordered and books sent out to individuals. I am trying to work out a way of...
3
3255
by: rogynskyy | last post by:
Hi guys, I'm running MSDE 2000 A on Win XP I've got a database with several tables, all of the tables display data in query manager. I wrote this simple query: Select
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9481
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10336
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.