Showing posts with label newbie. Show all posts
Showing posts with label newbie. Show all posts

Thursday, March 29, 2012

Count records manually

Hi everyone, I'm a newbie with this Crystal Reports thing and I was wondering if there is anyone who can help me.

My table has a field named obsolete, depending on the type of "obsolete" I would like to count the number of ocurrencies in my table.

I know I could do this by grouping the field but, I need to group with other 4 fields and I've tried it like that but I guess that the only way that I'll be able to retrieve the data the way I want it is manually. So, is there any if statement or while statement that I could use?

Thanx for any repliesI guess you could try to use if statements in suppressed formulas (look up information on running totals in CR).

I had a similar requirement and found it easier to decode the values in my view (I'm using Oracle PL/SQL).

decode(classId,1,trafficcount,0) class_1,
decode(classId,2,trafficcount,0) class_2,

Ie. If the classId is 1, put the trafficcount in column called class_1, else put 0.|||Thanx for your reply kristyw. Im using informix, I'm not quite sure I can use the decode function, or is it a CR function?

Tuesday, March 27, 2012

count number of connections in sql

This is probably a newbie quesiton, but I would like to be able to count how
many users connect to my db for evvery 30 minutes. How may I do this within
sql 2k?
Thank you in advanceSELECT COUNT(DISTINCT spid) FROM master..sysprocesses WHERE spid > 50
This is my signature. It is a general reminder.
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.
"Carl Henthorn" <CarlHenthorn@.discussions.microsoft.com> wrote in message
news:06F88966-654C-449D-8085-9F87DC7455DF@.microsoft.com...
> This is probably a newbie quesiton, but I would like to be able to count
> how
> many users connect to my db for evvery 30 minutes. How may I do this
> within
> sql 2k?
> Thank you in advance|||Thank you for responding! I think that this code will give me a snapshot of
how many are connected at a given time, but I need to know how many total
have connected in the last 30 minutes. perhaps I can place a trigger on this
table that updates a count in another table whenever a new process (where
spid>50) is spawned?
"Aaron [SQL Server MVP]" wrote:

> SELECT COUNT(DISTINCT spid) FROM master..sysprocesses WHERE spid > 50
> --
> This is my signature. It is a general reminder.
> Please post DDL, sample data and desired results.
> See http://www.aspfaq.com/5006 for info.
>
> "Carl Henthorn" <CarlHenthorn@.discussions.microsoft.com> wrote in message
> news:06F88966-654C-449D-8085-9F87DC7455DF@.microsoft.com...
>
>|||No trigger on system tables, sorry. You will have to poll the table
constantly. Plus, if I connect and get assigned spid 52, you poll, then I
disconnect and someone else connects and gets assigned 52, you won't see the
difference unless you compare the deltas in all columns (which still might
not yield a discrepancy).
You might consider tracking this more from the application side, e.g. if you
have a GUI where people are logging in, then in the stored procedure that
checks their credentials, log the connection in some table. SQL Server
isn't going to provide you this kind of information directly.
This is my signature. It is a general reminder.
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.
"Carl Henthorn" <CarlHenthorn@.discussions.microsoft.com> wrote in message
news:D84485D0-59F2-4298-89DC-04AFDC5B29DA@.microsoft.com...
> Thank you for responding! I think that this code will give me a snapshot
> of
> how many are connected at a given time, but I need to know how many total
> have connected in the last 30 minutes. perhaps I can place a trigger on
> this
> table that updates a count in another table whenever a new process (where
> spid>50) is spawned?
> "Aaron [SQL Server MVP]" wrote:
>|||Thank you for your help!!
"Aaron [SQL Server MVP]" wrote:

> No trigger on system tables, sorry. You will have to poll the table
> constantly. Plus, if I connect and get assigned spid 52, you poll, then I
> disconnect and someone else connects and gets assigned 52, you won't see t
he
> difference unless you compare the deltas in all columns (which still might
> not yield a discrepancy).
> You might consider tracking this more from the application side, e.g. if y
ou
> have a GUI where people are logging in, then in the stored procedure that
> checks their credentials, log the connection in some table. SQL Server
> isn't going to provide you this kind of information directly.
> --
> This is my signature. It is a general reminder.
> Please post DDL, sample data and desired results.
> See http://www.aspfaq.com/5006 for info.
>
> "Carl Henthorn" <CarlHenthorn@.discussions.microsoft.com> wrote in message
> news:D84485D0-59F2-4298-89DC-04AFDC5B29DA@.microsoft.com...
>
>