Sunday, March 11, 2012

Another query help question

Similar to my other question, but the counting is different. Thank you
again for your help.
CREATE TABLE [dbo].[Tracking] (
[key_] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[value_] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL )
insert into tracking VALUES ('EVENT','verbal aggression')
insert into tracking VALUES ('EVENT','peer')
insert into tracking VALUES ('EVENT','bad behavior')
insert into tracking VALUES ('EVENT','other')
insert into tracking VALUES ('PRELIM','Loud noise')
insert into tracking VALUES ('PRELIM','agitation')
insert into tracking VALUES ('PRELIM','schedule change')
insert into tracking VALUES ('PRELIM','meal time')
CREATE TABLE [dbo].[Tracking_DATA] (
[ID_] [int] IDENTITY (1, 1) NOT NULL ,
[bts_ID_] [int] NULL ,
[key_] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[value_] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
insert into tracking_DATA VALUES (1, 'EVENT', 'other')
insert into tracking_DATA VALUES (1, 'EVENT', 'bad behavior')
insert into tracking_DATA VALUES (1, 'PRELIM', 'Loud noise')
insert into tracking_DATA VALUES (1, 'PRELIM', 'agitation')
insert into tracking_DATA VALUES (2, 'EVENT', 'other')
insert into tracking_DATA VALUES (2, 'EVENT', 'verbal aggression')
insert into tracking_DATA VALUES (2, 'PRELIM', 'Loud noise')
event prelim count
other loud noise 2
other agitation 1
bad behavior loud noise 1
bad behavior agitation 1
verbal aggression loud noise 1
peer <BLANK> 0Hi
Can you say how the information is grouped to get these values?
John
"Jack" wrote:

> Similar to my other question, but the counting is different. Thank you
> again for your help.
> CREATE TABLE [dbo].[Tracking] (
> [key_] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [value_] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL )
> insert into tracking VALUES ('EVENT','verbal aggression')
> insert into tracking VALUES ('EVENT','peer')
> insert into tracking VALUES ('EVENT','bad behavior')
> insert into tracking VALUES ('EVENT','other')
> insert into tracking VALUES ('PRELIM','Loud noise')
> insert into tracking VALUES ('PRELIM','agitation')
> insert into tracking VALUES ('PRELIM','schedule change')
> insert into tracking VALUES ('PRELIM','meal time')
>
> CREATE TABLE [dbo].[Tracking_DATA] (
> [ID_] [int] IDENTITY (1, 1) NOT NULL ,
> [bts_ID_] [int] NULL ,
> [key_] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [value_] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ) ON [PRIMARY]
> GO
> insert into tracking_DATA VALUES (1, 'EVENT', 'other')
> insert into tracking_DATA VALUES (1, 'EVENT', 'bad behavior')
> insert into tracking_DATA VALUES (1, 'PRELIM', 'Loud noise')
> insert into tracking_DATA VALUES (1, 'PRELIM', 'agitation')
> insert into tracking_DATA VALUES (2, 'EVENT', 'other')
> insert into tracking_DATA VALUES (2, 'EVENT', 'verbal aggression')
> insert into tracking_DATA VALUES (2, 'PRELIM', 'Loud noise')
>
> event prelim count
> other loud noise 2
> other agitation 1
> bad behavior loud noise 1
> bad behavior agitation 1
> verbal aggression loud noise 1
> peer <BLANK> 0
>
>

No comments:

Post a Comment