473,765 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting Count(*) when using pseudo pivot tables...

In the usual case, this SQL

select count(*) from mytable where ...

returns an accurate count of the rows you want.

But how do I go about counting rows from this SQL (the sum...if
statements function as a pseudo pivot query)?
SELECT sum(IF(date_rep ort = ('2005-06-30'),shares,0)) as 'Q2
2005',sum(IF(da te_report = '2005-03-31',shares,0)) as 'Q1 2005' from
companies left join positions on co_id = positions_co_id where
positions_co_is sue_id = 7194 AND date_report
in('2005-06-30','2005-03-31') group by co_id order by 'Q2 2005' DESC
In this case, I'll end up with a row count of, say, 360. When I try to
count the rows I come up with numbers way different. For instance, this try:

select count(co_id) from companies left join positions on co_id =
positions_co_id where positions_co_is sue_id = 7194 AND date_report
in('2005-06-30','2005-03-31')

....might give me 1000, while this one...

select count( distinct co_id) from companies left join positions on
co_id = positions_co_id where positions_co_is sue_id = 7194 AND
date_report in('2005-06-30','2005-03-31')

....might give me 320.

I'd sure appreciate any thoughts!

--Brent
Oct 23 '05 #1
0 1397

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

Similar topics

1
5280
by: Clive Moss | last post by:
I am in the middle of writing a system for a client who has Access 2000 installed on 8 PC's I have Access 2002 and the system I have written relies on pivot tables to display results. I now find that 2000 does not support them. Is there a way (an add-in or something) that the client can get to display pivot tables? TIA
4
3023
by: Del | last post by:
I need to create Pivot table in Excel from Access. Currently I run a query and output the data to an excel worksheet and create the pivots via automation. The issue I face is that the query may return more than 65000 rows of data. Is there a way I can create the Pivot tables without having to output the data to excel first? Any help would be appreciated.
2
23941
by: Joe | last post by:
Hi All, I am new to using the Access DB and I need some help if someone is able to give it to me. What I want to do is get the names of the columns of certain tables. Not the data in the table but the table column names. I've seen other posts that suggest using the SQL command DESCRIBE but I can't get it to work for some reason. Other posts have code samples but they're written in VB which I am not familiar with. I
0
1583
by: Dave | last post by:
I am trying to develop Data Access Pages (DAP) within Access 2003, specifically using Pivot Table Lists. When creating pivot tables as forms, all of my records in a table consisting of over 18,000 records are represented, however, when using pivot tables on a DAP, or even without using pivot table, only the first 10,000 records are represented. Is there a limitation of only 10,000 records, or is there something else that can be adjusted...
2
3146
by: cefrancke | last post by:
I can't seem to find a straight answer for my specific issue. Any help would be appreciated. I would like to count the various items in a table where the fields have a 'group' relationship. I would like to count the items per group. (Please forgive the inappropriate use of database terms.) An example follows:
3
5849
by: George Sakkis | last post by:
After a brief search, I didn't find any python package related to OLAP and pivot tables. Did I miss anything ? To be more precise, I'm not so interested in a full-blown OLAP server with an RDBMS backend, but rather a pythonic API for constructing datacubes in memory, slicing and dicing them, drilling down or up dimensions and exposing them in some suitable form to a presentation layer. I've hacked a first cut of a pivot table...
4
3079
by: dallasfreeman | last post by:
I'm looking at a quick way to get results that are displayed as rows to display as columns. I have three tables:- - The Questions for the survey - The Results of the survey (Columns are listed as question numbers) - The Survey Extra Results (As additional questions can be listed into the Questions table, has 3 columns (a link/id to the survey id, a link/id to the question id, and the answer the user gave).
22
12491
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source=" & msDbFilename moConn.Properties("Persist Security Info") = False moConn.ConnectionString = msConnString moConn.CursorLocation = adUseClient moConn.Mode = adModeReadWrite' or using default...same result
3
2574
by: Thyag | last post by:
Hi All, I need to group multiple tables in to a pivot. Could some body help me. Thanks in Advance, Thyag
0
9568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5277
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3926
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.