473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Need help with count

kjc
Is it possible to obtain a count of the number of rows that would
be returned based on the following query.

select tableA.*,
tableB.fieldA,
tableB.fieldB,
tableB.fieldC,
tableC.fieldA,
tableD.fieldA,
tableD.fieldB
from tableA,
tableB,
tableC,
tableD
where
PREDICATES
group by
ALL FIELDS in the select
Thanks in advance.

Jul 23 '05 #1
4 1208
kjc (ks*****@elp.rr.com) writes:
Is it possible to obtain a count of the number of rows that would
be returned based on the following query.

select tableA.*,
tableB.fieldA,
tableB.fieldB,
tableB.fieldC,
tableC.fieldA,
tableD.fieldA,
tableD.fieldB
from tableA,
tableB,
tableC,
tableD
where
PREDICATES
group by
ALL FIELDS in the select


select COUNT(*)
from tableA,
tableB,
tableC,
tableD
where
PREDICATES
group by
ALL FIELDS in the select

If you only want read the table once you can insert into a temp table,
and check @@rowcount after the INSERT.


--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2
kjc
Thanks for the reply Erland, but, I tried what you proposed.
What I get back is the number of rows returned by the select
all with the number 1 in each column.

Thanks again.

Erland Sommarskog wrote:
kjc (ks*****@elp.rr.com) writes:
Is it possible to obtain a count of the number of rows that would
be returned based on the following query.

select tableA.*,
tableB.fieldA,
tableB.fieldB,
tableB.fieldC,
tableC.fieldA,
tableD.fieldA,
tableD.fieldB
from tableA,
tableB,
tableC,
tableD
where
PREDICATES
group by
ALL FIELDS in the select

select COUNT(*)
from tableA,
tableB,
tableC,
tableD
where
PREDICATES
group by
ALL FIELDS in the select

If you only want read the table once you can insert into a temp table,
and check @@rowcount after the INSERT.


Jul 23 '05 #3
On Fri, 10 Dec 2004 15:27:44 GMT, kjc wrote:
Thanks for the reply Erland, but, I tried what you proposed.
What I get back is the number of rows returned by the select
all with the number 1 in each column.


Hi kjc,

Try this one instead:

SELECT COUNT(*)
FROM (
select tableA.*,
tableB.fieldA,
tableB.fieldB,
tableB.fieldC,
tableC.fieldA,
tableD.fieldA,
tableD.fieldB
from tableA,
tableB,
tableC,
tableD
where
PREDICATES
group by
ALL FIELDS in the select
) AS x

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 23 '05 #4
kjc
Thanks Hugo,
U GO !!

Hugo Kornelis wrote:
On Fri, 10 Dec 2004 15:27:44 GMT, kjc wrote:

Thanks for the reply Erland, but, I tried what you proposed.
What I get back is the number of rows returned by the select
all with the number 1 in each column.

Hi kjc,

Try this one instead:

SELECT COUNT(*)
FROM (
select tableA.*,
tableB.fieldA,
tableB.fieldB,
tableB.fieldC,
tableC.fieldA,
tableD.fieldA,
tableD.fieldB
from tableA,
tableB,
tableC,
tableD
where
PREDICATES
group by
ALL FIELDS in the select
) AS x

Best, Hugo


Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rohit Raghuwanshi | last post by:
Hello all, we are running a delphi application with DB2 V8.01 which is causing deadlocks when rows are being inserted into a table. Attaching the Event Monitor Log (DEADLOCKS WITH DETAILS) here....
66
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it...
1
by: rllioacvuher | last post by:
I need help with a program. I have implemented that following header file with an unordered list using one array, but i need to be able to use an ordered list and 2 arrays (one for the links and one...
4
by: J | last post by:
I've spent most of the day on this, and I just can't seem to find a solution, please help me! :) I'm recieving XML that I can't modify that looks like: <?xml version="1.0"?> <Doc> <Page>...
1
by: satan | last post by:
I need a help with the program to test the insertion, deletion, search, copyList, and the copy constructor operations for an object in the class UnorderedLinkedList. These are my classes: ...
7
by: satan | last post by:
I need a help with the program to test the insertion, deletion, search, copyList, and the copy constructor operations for an object in the class UnorderedLinkedList. These are my classes: ...
4
by: naknak4 | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
6
by: naknak | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
0
by: doobybug | last post by:
Hi all, I really need your help! I am new to java and have some problems with my code. I have a program which inputs questionnaires and creates an object for each questionnaire. These objects are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.