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
 General SQL Server Forums
 New to SQL Server Programming
 easy search query but too difficult for me :S

Author  Topic 

dustinkovich
Starting Member

1 Post

Posted - 2009-07-03 : 13:47:34
Hi,

Can someone please help me.

I have a table definition as

USE [Reports]
GO
/****** Object: Table [dbo].[Temp] Script Date: 07/03/2009 13:43:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Temp](
[id] [int] IDENTITY(1,1) NOT NULL,
[AdGroup] [nvarchar](50) NULL,
[Clicks] [int] NULL,
CONSTRAINT [PK_Temp] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]


Sample data would be

AdGroup = Google, Clicks = 2,
AdGroup = MSN, Clicks = 3,
AdGroup = Google, Clicks = 1,
AdGroup = Yahoo, Clicks = 2
etc..

How do I write a query that will show me how many "Clicks" there have been per "AdGroup"?

Thanks in advance :D

Dustin

singularity
Posting Yak Master

153 Posts

Posted - 2009-07-03 : 13:49:21
select AdGroup, sum(Clicks) as Clicks
from Temp
group by AdGroup
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-05 : 03:14:43
it might be better for you to add an audit column like dateentered as well if you need to analyse the clicks per adgroup per day,month,year,..
Go to Top of Page
   

- Advertisement -