Need help with multiple SELECT using multiple COUNTs 
Author Message
 Need help with multiple SELECT using multiple COUNTs

I am creating a page which gives a report of user activity for a call
center. I want to return the number of "comments" that user opened &
closed during a time period and the total amount they currently have
opened. So far I have created a SQL statement that returns the total
open during a time period, but I have not been able to include the
other 2 columns in the result. I want a user to be returned if s/he
opened or closed any comments during the time period, or currently has
any open. I'm not sure how to do all of this. Thanks!

sql =   "SELECT "&_
                  "  tblUsers.strFamily, "&_
                  "  tblUsers.strGiven, "&_
                  "  COUNT (tblComments.intCommentID) as totalOpened "&_
                  "FROM "&_
                  "  tblComments INNER JOIN "&_
                  "  ( "&_
                  "  tblEvents INNER JOIN "&_
                  "    tblUsers ON "&_
                  "    tblUsers.intUserID = "&_
                  "    tblEvents.intCreatorID "&_
                  "  ) "&_
                  "ON "&_
                  "  tblComments.intCommentID = "&_
                  "  tblEvents.intCommentID "&_
                  "WHERE "&_
                  "  tblEvents.intEventTypeID = 1 "&_
                  "  AND tblEvents.dtmDate BETWEEN "&_
                  "                '" & startDate & "' AND "&_
                  "                '" & endDate & "' "&_
                  "GROUP BY "&_
                  "  tblUsers.strFamily, "&_
                  "  tblUsers.strGiven "&_
                  "ORDER BY "&_
                  "  tblUsers.strGiven "



Wed, 17 Aug 2005 10:06:39 GMT
 Need help with multiple SELECT using multiple COUNTs

Dwayne,

The best way to request assistance with an SQL query is by posting (simplified) table schemas (CREATE TABLEs), sample data (INSERTs), and the results you want using that sample data. Posting a query that does not do what you want without the information listed above is of minimal value to others.

-------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.

Quote:

> I am creating a page which gives a report of user activity for a call
> center. I want to return the number of "comments" that user opened &
> closed during a time period and the total amount they currently have
> opened. So far I have created a SQL statement that returns the total
> open during a time period, but I have not been able to include the
> other 2 columns in the result. I want a user to be returned if s/he
> opened or closed any comments during the time period, or currently has
> any open. I'm not sure how to do all of this. Thanks!

> sql = "SELECT "&_
>   "  tblUsers.strFamily, "&_
>   "  tblUsers.strGiven, "&_
>   "  COUNT (tblComments.intCommentID) as totalOpened "&_
>   "FROM "&_
>   "  tblComments INNER JOIN "&_
>   "  ( "&_
>   "  tblEvents INNER JOIN "&_
>   "    tblUsers ON "&_
>   "    tblUsers.intUserID = "&_
>   "    tblEvents.intCreatorID "&_
>   "  ) "&_
>   "ON "&_
>   "  tblComments.intCommentID = "&_
>   "  tblEvents.intCommentID "&_
>   "WHERE "&_
>   "  tblEvents.intEventTypeID = 1 "&_
>     "  AND tblEvents.dtmDate BETWEEN "&_
>     "                '" & startDate & "' AND "&_
>   "                '" & endDate & "' "&_
>     "GROUP BY "&_
>     "  tblUsers.strFamily, "&_
>   "  tblUsers.strGiven "&_
>     "ORDER BY "&_
>     "  tblUsers.strGiven "



Wed, 17 Aug 2005 12:30:51 GMT
 Need help with multiple SELECT using multiple COUNTs
Thanks Margolin,
Below are the table schemas and some INSERTS. The results that I would
like would show the users name, the total amount of comments that each
user opened or closed on January 11th, 1981, and the total number of
comments that are still open and assigned to the user. BTW, if
tblEvents.intEvenTypeID is set to 1 then that is an open event, or if
it is set to 2 than it is a close event. To find out who a comment
currently is assigned to you can check the tblComments.intUserID. Have
I left anything out?

First & Last   | Opened | Closed | Currently Open |
---------------------------------------------------
Dwayne Forehand|   2    |    1   |       1        |
Mickey Mouse   |   2    |    2   |                |

CREATE TABLE [tblComments] (
        [intCommentID] [int] IDENTITY (1, 1) NOT NULL ,
        [intLocationID] [int] NOT NULL ,
        [intCategoryID] [int] NOT NULL ,
        [intUserID] [int] NULL ,
        [strDescription] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
        [intRecievedVia] [smallint] NULL ,
        [strName] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
        [strEmail] [nvarchar] (75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
        [strStreet1] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
        [strStreet2] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
        [strApartment] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
        [strCity] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
        [strState] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
        [strZip] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
        [strPhone] [nvarchar] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
        [intUrgent] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [tblEvents] (
        [intEventID] [int] IDENTITY (1, 1) NOT NULL ,
        [intCommentID] [int] NULL ,
        [intEventTypeID] [int] NULL ,
        [intCreatorID] [int] NULL ,
        [intRecieverID] [int] NULL ,
        [dtmDate] [smalldatetime] NULL
) ON [PRIMARY]
GO

CREATE TABLE [tblUsers] (
        [intUserID] [int] IDENTITY (1, 1) NOT NULL ,
        [strFamily] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
        [strGiven] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
        [strPhone] [nvarchar] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
        [strEmail] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
        [strLogon] [nvarchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
        [intSecurityLevel] [smallint] NULL
) ON [PRIMARY]
GO

INSERT INTO [cts].[dbo].[tblUsers]([strFamily], [strGiven],
[strPhone], [strEmail], [strLogon], [intSecurityLevel])
VALUES('Forehand', 'Dwayne', '425-772-2643',

GO

INSERT INTO [cts].[dbo].[tblUsers]([strFamily], [strGiven],
[strPhone], [strEmail], [strLogon], [intSecurityLevel])

'mm7', 6)

GO

INSERT INTO [cts].[dbo].[tblComments]([intLocationID],
[intCategoryID], [intUserID], [strDescription], [intRecievedVia],
[strName], [strEmail], [strStreet1], [strStreet2], [strApartment],
[strCity], [strState], [strZip], [strPhone], [intUrgent])
VALUES(1, 1, 1, 'd', 1, 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
0)

GO

INSERT INTO [cts].[dbo].[tblComments]([intLocationID],
[intCategoryID], [intUserID], [strDescription], [intRecievedVia],
[strName], [strEmail], [strStreet1], [strStreet2], [strApartment],
[strCity], [strState], [strZip], [strPhone], [intUrgent])
VALUES(1, 1, 1, 'd', 1, 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
0)

GO

INSERT INTO [cts].[dbo].[tblComments]([intLocationID],
[intCategoryID], [intUserID], [strDescription], [intRecievedVia],
[strName], [strEmail], [strStreet1], [strStreet2], [strApartment],
[strCity], [strState], [strZip], [strPhone], [intUrgent])
VALUES(1, 1, 2, 'd', 1, 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
0)

GO

INSERT INTO [cts].[dbo].[tblComments]([intLocationID],
[intCategoryID], [intUserID], [strDescription], [intRecievedVia],
[strName], [strEmail], [strStreet1], [strStreet2], [strApartment],
[strCity], [strState], [strZip], [strPhone], [intUrgent])
VALUES(1, 1, 2, 'd', 1, 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
0)

GO

INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
[intCreatorID], [intRecieverID], [dtmDate])
VALUES(1, 1, 1, 1, '01/11/81')

GO

INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
[intCreatorID], [intRecieverID], [dtmDate])
VALUES(1, 2, 2, 2, '01/11/81')

GO

INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
[intCreatorID], [intRecieverID], [dtmDate])
VALUES(2, 1, 2, 2, '01/11/81')

GO

INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
[intCreatorID], [intRecieverID], [dtmDate])
VALUES(2, 2, 1, 2, '01/11/81')

GO

INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
[intCreatorID], [intRecieverID], [dtmDate])
VALUES(3, 1, 2, 2, '01/11/81')

GO

INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
[intCreatorID], [intRecieverID], [dtmDate])
VALUES(3, 2, 2, 2, '01/11/81')

GO

INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
[intCreatorID], [intRecieverID], [dtmDate])
VALUES(4, 1, 1, 1, '01/11/81')

GO



Sun, 21 Aug 2005 05:50:58 GMT
 Need help with multiple SELECT using multiple COUNTs
Thanks Margolin,
Below are the table schemas and some INSERTS. The results that I would
like would show the users name, the total amount of comments that each
user opened or closed on January 11th, 1981, and the total number of
comments that are still open and assigned to the user. BTW, if
tblEvents.intEvenTypeID is set to 1 then that is an open event, or if
it is set to 2 than it is a close event. To find out who a comment
currently is assigned to you can check the tblComments.intUserID. Have
I left anything out?

First & Last   | Opened | Closed | Currently Open |
---------------------------------------------------
Dwayne Forehand|   2    |    1   |       1        |
Mickey Mouse   |   2    |    2   |                |

CREATE TABLE [tblComments] (
        [intCommentID] [int] IDENTITY (1, 1) NOT NULL ,
        [intLocationID] [int] NOT NULL ,
        [intCategoryID] [int] NOT NULL ,
        [intUserID] [int] NULL ,
        [strDescription] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
        [intRecievedVia] [smallint] NULL ,
        [strName] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
        [strEmail] [nvarchar] (75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
        [strStreet1] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
        [strStreet2] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
        [strApartment] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
        [strCity] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
        [strState] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
        [strZip] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
        [strPhone] [nvarchar] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
        [intUrgent] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [tblEvents] (
        [intEventID] [int] IDENTITY (1, 1) NOT NULL ,
        [intCommentID] [int] NULL ,
        [intEventTypeID] [int] NULL ,
        [intCreatorID] [int] NULL ,
        [intRecieverID] [int] NULL ,
        [dtmDate] [smalldatetime] NULL
) ON [PRIMARY]
GO

CREATE TABLE [tblUsers] (
        [intUserID] [int] IDENTITY (1, 1) NOT NULL ,
        [strFamily] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
        [strGiven] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
        [strPhone] [nvarchar] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
        [strEmail] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
        [strLogon] [nvarchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
        [intSecurityLevel] [smallint] NULL
) ON [PRIMARY]
GO

INSERT INTO [cts].[dbo].[tblUsers]([strFamily], [strGiven],
[strPhone], [strEmail], [strLogon], [intSecurityLevel])
VALUES('Forehand', 'Dwayne', '425-772-2643',

GO

INSERT INTO [cts].[dbo].[tblUsers]([strFamily], [strGiven],
[strPhone], [strEmail], [strLogon], [intSecurityLevel])

'mm7', 6)

GO

INSERT INTO [cts].[dbo].[tblComments]([intLocationID],
[intCategoryID], [intUserID], [strDescription], [intRecievedVia],
[strName], [strEmail], [strStreet1], [strStreet2], [strApartment],
[strCity], [strState], [strZip], [strPhone], [intUrgent])
VALUES(1, 1, 1, 'd', 1, 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
0)

GO

INSERT INTO [cts].[dbo].[tblComments]([intLocationID],
[intCategoryID], [intUserID], [strDescription], [intRecievedVia],
[strName], [strEmail], [strStreet1], [strStreet2], [strApartment],
[strCity], [strState], [strZip], [strPhone], [intUrgent])
VALUES(1, 1, 1, 'd', 1, 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
0)

GO

INSERT INTO [cts].[dbo].[tblComments]([intLocationID],
[intCategoryID], [intUserID], [strDescription], [intRecievedVia],
[strName], [strEmail], [strStreet1], [strStreet2], [strApartment],
[strCity], [strState], [strZip], [strPhone], [intUrgent])
VALUES(1, 1, 2, 'd', 1, 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
0)

GO

INSERT INTO [cts].[dbo].[tblComments]([intLocationID],
[intCategoryID], [intUserID], [strDescription], [intRecievedVia],
[strName], [strEmail], [strStreet1], [strStreet2], [strApartment],
[strCity], [strState], [strZip], [strPhone], [intUrgent])
VALUES(1, 1, 2, 'd', 1, 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
0)

GO

INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
[intCreatorID], [intRecieverID], [dtmDate])
VALUES(1, 1, 1, 1, '01/11/81')

GO

INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
[intCreatorID], [intRecieverID], [dtmDate])
VALUES(1, 2, 2, 2, '01/11/81')

GO

INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
[intCreatorID], [intRecieverID], [dtmDate])
VALUES(2, 1, 2, 2, '01/11/81')

GO

INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
[intCreatorID], [intRecieverID], [dtmDate])
VALUES(2, 2, 1, 2, '01/11/81')

GO

INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
[intCreatorID], [intRecieverID], [dtmDate])
VALUES(3, 1, 2, 2, '01/11/81')

GO

INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
[intCreatorID], [intRecieverID], [dtmDate])
VALUES(3, 2, 2, 2, '01/11/81')

GO

INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
[intCreatorID], [intRecieverID], [dtmDate])
VALUES(4, 1, 1, 1, '01/11/81')

GO



Sun, 21 Aug 2005 05:51:40 GMT
 Need help with multiple SELECT using multiple COUNTs
Dwayne,

Sometimes less is more   ;-)

It's best to post table schemas that are simplified as much as possible so that one doesn't lose the wheat because of the chaff  :-)

For example, I think the following is all the information that is probably needed, although admittedly this is a guess on my part:

/*
First & Last   | Opened | Closed | Currently Open |
---------------------------------------------------
Dwayne Forehand|   2    |    1   |       1        |
Mickey Mouse   |   2    |    2   |                |
*/

CREATE TABLE tblComments (
intCommentID int IDENTITY (1, 1) NOT NULL ,
intLocationID int NOT NULL ,
intCategoryID int NOT NULL ,
intUserID int NULL
)

CREATE TABLE tblEvents (
intEventID int IDENTITY (1, 1) NOT NULL ,
intCommentID int NULL ,
intEventTypeID int NULL ,
intCreatorID int NULL ,
intRecieverID int NULL ,
dtmDate smalldatetime NULL
)

CREATE TABLE tblUsers (
intUserID int IDENTITY (1, 1) NOT NULL ,
strFamily nvarchar (50) NULL ,
strGiven nvarchar (50) NULL
)
GO

INSERT INTO dbo.tblUsers(strFamily, strGiven) VALUES('Forehand', 'Dwayne')
INSERT INTO dbo.tblUsers(strFamily, strGiven) VALUES('Mouse', 'Mickey')

INSERT INTO dbo.tblComments(intLocationID, intCategoryID, intUserID) VALUES(1, 1, 1)
INSERT INTO dbo.tblComments(intLocationID, intCategoryID, intUserID) VALUES(1, 1, 1)
INSERT INTO dbo.tblComments(intLocationID, intCategoryID, intUserID) VALUES(1, 1, 2)
INSERT INTO dbo.tblComments(intLocationID, intCategoryID, intUserID) VALUES(1, 1, 2)

INSERT INTO dbo.tblEvents(intCommentID, intEventTypeID) VALUES(1, 1)
INSERT INTO dbo.tblEvents(intCommentID, intEventTypeID) VALUES(1, 2)
INSERT INTO dbo.tblEvents(intCommentID, intEventTypeID) VALUES(2, 1)
INSERT INTO dbo.tblEvents(intCommentID, intEventTypeID) VALUES(2, 2)
INSERT INTO dbo.tblEvents(intCommentID, intEventTypeID) VALUES(3, 1)
INSERT INTO dbo.tblEvents(intCommentID, intEventTypeID) VALUES(3, 2)
INSERT INTO dbo.tblEvents(intCommentID, intEventTypeID) VALUES(4, 1)

You might have posted how to determine an "Opened" status, and a "Closed" status, and a "Currently Open" status earlier, but I don't keep old posts around, and it's not immediately clear to me from the data how to determine these statuses. Perhaps, you could post how to determine the various statuses, or, perhaps if you already have done that in your earlier post, someone else who does keep old posts will be able to supply the query.

If someone else doesn't jump in, then please "take pity on me", and when posting how to determine the statuses, repost the table schemas and sample data also, or simply let your email reader append this post to your reply   :-)

-------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.

Quote:

> Thanks Margolin,
> Below are the table schemas and some INSERTS. The results that I would
> like would show the users name, the total amount of comments that each
> user opened or closed on January 11th, 1981, and the total number of
> comments that are still open and assigned to the user. BTW, if
> tblEvents.intEvenTypeID is set to 1 then that is an open event, or if
> it is set to 2 than it is a close event. To find out who a comment
> currently is assigned to you can check the tblComments.intUserID. Have
> I left anything out?

> First & Last   | Opened | Closed | Currently Open |
> ---------------------------------------------------
> Dwayne Forehand|   2    |    1   |       1        |
> Mickey Mouse   |   2    |    2   |                |

> CREATE TABLE [tblComments] (
> [intCommentID] [int] IDENTITY (1, 1) NOT NULL ,
> [intLocationID] [int] NOT NULL ,
> [intCategoryID] [int] NOT NULL ,
> [intUserID] [int] NULL ,
> [strDescription] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [intRecievedVia] [smallint] NULL ,
> [strName] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [strEmail] [nvarchar] (75) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ,
> [strStreet1] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
> NULL ,
> [strStreet2] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
> NULL ,
> [strApartment] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS
> NULL ,
> [strCity] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [strState] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ,
> [strZip] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [strPhone] [nvarchar] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ,
> [intUrgent] [int] NULL
> ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
> GO

> CREATE TABLE [tblEvents] (
> [intEventID] [int] IDENTITY (1, 1) NOT NULL ,
> [intCommentID] [int] NULL ,
> [intEventTypeID] [int] NULL ,
> [intCreatorID] [int] NULL ,
> [intRecieverID] [int] NULL ,
> [dtmDate] [smalldatetime] NULL
> ) ON [PRIMARY]
> GO

> CREATE TABLE [tblUsers] (
> [intUserID] [int] IDENTITY (1, 1) NOT NULL ,
> [strFamily] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ,
> [strGiven] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ,
> [strPhone] [nvarchar] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ,
> [strEmail] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ,
> [strLogon] [nvarchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [intSecurityLevel] [smallint] NULL
> ) ON [PRIMARY]
> GO

> INSERT INTO [cts].[dbo].[tblUsers]([strFamily], [strGiven],
> [strPhone], [strEmail], [strLogon], [intSecurityLevel])
> VALUES('Forehand', 'Dwayne', '425-772-2643',

> GO

> INSERT INTO [cts].[dbo].[tblUsers]([strFamily], [strGiven],
> [strPhone], [strEmail], [strLogon], [intSecurityLevel])

> 'mm7', 6)

> GO

> INSERT INTO [cts].[dbo].[tblComments]([intLocationID],
> [intCategoryID], [intUserID], [strDescription], [intRecievedVia],
> [strName], [strEmail], [strStreet1], [strStreet2], [strApartment],
> [strCity], [strState], [strZip], [strPhone], [intUrgent])
> VALUES(1, 1, 1, 'd', 1, 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
> 0)

> GO

> INSERT INTO [cts].[dbo].[tblComments]([intLocationID],
> [intCategoryID], [intUserID], [strDescription], [intRecievedVia],
> [strName], [strEmail], [strStreet1], [strStreet2], [strApartment],
> [strCity], [strState], [strZip], [strPhone], [intUrgent])
> VALUES(1, 1, 1, 'd', 1, 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
> 0)

> GO

> INSERT INTO [cts].[dbo].[tblComments]([intLocationID],
> [intCategoryID], [intUserID], [strDescription], [intRecievedVia],
> [strName], [strEmail], [strStreet1], [strStreet2], [strApartment],
> [strCity], [strState], [strZip], [strPhone], [intUrgent])
> VALUES(1, 1, 2, 'd', 1, 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
> 0)

> GO

> INSERT INTO [cts].[dbo].[tblComments]([intLocationID],
> [intCategoryID], [intUserID], [strDescription], [intRecievedVia],
> [strName], [strEmail], [strStreet1], [strStreet2], [strApartment],
> [strCity], [strState], [strZip], [strPhone], [intUrgent])
> VALUES(1, 1, 2, 'd', 1, 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
> 0)

> GO

> INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
> [intCreatorID], [intRecieverID], [dtmDate])
> VALUES(1, 1, 1, 1, '01/11/81')

> GO

> INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
> [intCreatorID], [intRecieverID], [dtmDate])
> VALUES(1, 2, 2, 2, '01/11/81')

> GO

> INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
> [intCreatorID], [intRecieverID], [dtmDate])
> VALUES(2, 1, 2, 2, '01/11/81')

> GO

> INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
> [intCreatorID], [intRecieverID], [dtmDate])
> VALUES(2, 2, 1, 2, '01/11/81')

> GO

> INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
> [intCreatorID], [intRecieverID], [dtmDate])
> VALUES(3, 1, 2, 2, '01/11/81')

> GO

> INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
> [intCreatorID], [intRecieverID], [dtmDate])
> VALUES(3, 2, 2, 2, '01/11/81')

> GO

> INSERT INTO [cts].[dbo].[tblEvents]([intCommentID], [intEventTypeID],
> [intCreatorID], [intRecieverID], [dtmDate])
> VALUES(4, 1, 1, 1, '01/11/81')

> GO



Sun, 21 Aug 2005 23:44:38 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. need help using table multiple times within select

2. Help, having trouble with using count distinct multiple columns

3. Need help with select permission on multiple tables

4. Selecting XML into an ADO Stream using multiple select statements

5. select multiple count(*)s?

6. multiple COUNTs in select -- in a crunch

7. Multiple SPs or single SP with multiple selects?

8. Multiple database - multiple query - multiple server

9. Advice needed: Multiple instances vs Multiple users in 1 instance

10. Need to print multiple forms of multiple records

11. Help: Query with GROUP BY and multiple qualified COUNTs

12. Multiple tables, multiple results - HELP!!


 
Powered by phpBB® Forum Software