Martin writes
"Hi, I was wondering if it is possible to have
more that one count function in one sql statement. Say something
like: I would like to return how many times "reference" eq 1 and
how many times "refenrece" eq 2, so i get two fields back, one
counting the number of records where "reference" eq 1 and the other
counting the number of records where "reference" eq 2. Thanks."
It certainly is possible. If you want to know how many times a
given field contains a certain
value you can use a GROUP BY clause.
The code might look something like this:
Laptop Battery SELECT Reference, Record_Count=Count(*)
FROM Table1
GROUP BY Reference
SELECT DISTINCTROW hits.flyerid, Count(*) AS [Count Of hits] FROM hits GROUP BY hits.flyerid; Please can you tell how to combine these into one sql statment that can be executed from an asp page. Thanks for your time and help. kieron" We don't normally handle Access questions and after you see my SQL statement you'll understand why. I'm going to show you the answer in SQL Server syntax (mostly) and let you convert it to Access.
Thinkpad This will return one row per value with a count of how many
times that value occured. You could use a WHERE clause to only
display certain records. This does create a record set for you to
loop through though. If you truly want one record with two values
you can code something like this:
According to the indictment, Jones would steal various IBM and Penguin computer servers from Verisign's warehouse in Virginia and sell them to Johnson. Johnson would then sell the servers to several individuals, who would sometimes place them for sale on eBay. As a result of this scheme, the indictment alleges that Jones and Johnson caused Verisign to lose more than $120, 000 worth of computer equipment. In the indictment, Jones and Johnson are charged in three counts with causing the interstate transportation of stolen property, namely IBM 330 and 335 servers, in violation of 18 U.S.C.
Microsoft SELECT
Count_1=(SELECT Count(*) FROM Table1 WHERE Reference = 1),
Count_2=(SELECT Count(*) FROM Table1 WHERE Reference = 2)
Ok, this has to be one of the coolest things I've discoverd about SQL Server in quite a while. It is a way to create a sequential record number field on a table using a single update statement. Until I discovered this, I would have said this was impossible. Read on for the solution. While digging around in SQL Server recently I discovered something very interesting.
Laptop Computers Note that the outside SELECT has no table in it. It is simpy
used to return the results from the two subqueries. In this
scenario it is also possible to SELECT from different tables or use
different fields to generate results. This solution works better
the more complex the WHERE clauses are.
Computer memory is the quickest, cheapest, and easiest way to improve the performance of your system. Find RAM memory upgrades for desktops, laptops, servers, and printers all backed by a lifetime warranty and guaranteed compatible with your computer. Shipping is an everyday low price of $1.99! Computer Memory Outlet sells memory compatible with all leading computer manufacturers like Dell, Apple, Compaq, HP, Sony, IBM, Lenovo, and many more.”
[ Comment, Edit or Article Submission ]