Count(aaa) Giving Error... (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


WingMan -> Count(aaa) Giving Error... (12/7/2005 15:49:36)

Hey,

This seems to be an easy one, but I have yet to figure it out... more the fact that I am fairly new to FP, SQL and Access.

Okay, so basically I have a page that has a drop-down box that passes along a parameter to 3 seperate queries on the page. The parameter is named D1 (as in drop-down 1 I guess). The parameter is a number (1, 2, 3 or 6). Note, that each query works fine when the parameter is hard coded in (i.e. instead of D1 I put 1).

The first query works fine, and is:

SELECT arena_name
FROM arenas
WHERE (((arenas.arena_id)=::D1::));

The second query is the one the fails, and is:

SELECT [won]+[lost]+[tied] AS GP, Count(sched.win) AS Won, (SELECT Count(sched.win) FROM sched
WHERE (((sched.win)=2) AND ((sched.arena)=::D1::));) AS Lost, (SELECT Count(sched.win) FROM sched
WHERE (((sched.win)=3) AND ((sched.arena)=::D1::));) AS Tied
FROM sched
WHERE (((sched.win)=1) AND ((sched.arena)=::D1::));

The third query works fine, and is:

SELECT sched.date, sched.o_team, sched.o_score, sched.vs, sched.m_score, sched.m_team
FROM sched
WHERE (((sched.arena)=::D1::));

Any direction would be greatly appreciated!

Thanks,
WM




rdouglass -> RE: Count(aaa) Giving Error... (12/7/2005 16:13:13)

quote:

SELECT [won]+[lost]+[tied] AS GP, Count(sched.win) AS Won, (SELECT Count(sched.win) FROM sched
WHERE (((sched.win)=2) AND ((sched.arena)=::D1::));) AS Lost, (SELECT Count(sched.win) FROM sched
WHERE (((sched.win)=3) AND ((sched.arena)=::D1::));) AS Tied
FROM sched
WHERE (((sched.win)=1) AND ((sched.arena)=::D1::));


That looks a little messy and I personally wouldn't even attempt that (nothing personal just me) [;)]

What I would consider doing is something like this:

SELECT Count(sched.win) AS myCount WHERE (sched.arena)=::D1:: ORDER BY sched.win

If all you have is 1,2,3, or 6, you should get 4 records back:
Count for sched.win =1
Count for sched.win =2
Count for sched.win =3
Count for sched.win =6

in that order. Seems quite a bit simpler IMO. That help any?

EDIT: Oh yeah, Hi and Welcome to OutFront. [;)]




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625