473,396 Members | 1,987 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,396 software developers and data experts.

afficher 2 count de de tables

Bonjour je cherche à afficher de count de tables identiques dans la forme

exemple

num_cli | nombre de poste | nombre de voiture
1 1 3
2 2 5
3 1 0
45 4 6

deux tables poste et voitures par exemple

merci pour votre aide
thierry
Nov 12 '05 #1
4 1536
Could you describe by English?
Or, show sample source data and expected results.

Nov 12 '05 #2
"Tonkuma" <to*****@jp.ibm.com> wrote in message news:<11*********************@o13g2000cwo.googlegr oups.com>...
Could you describe by English?
Or, show sample source data and expected results.


Sory, I try to
I want to know if in sql it is possible to use count function with 2 tables.
Something like select t1.num, count(t1.car), count(t2.customer)...from t1,t2

and having in result

num count(t1.car) count(t2.customer)
1 5 6
2 4 3
3 0 1

thanks
Thierry
Nov 12 '05 #3
Assuming you want to count the number of rows in each table that have
matching values for a single column (num_cli), you have the following to do:
1. get counts for each table
2. merge the results

This is complicated by the possibility of having non-matching values in
num_cli for the tables. Application data rules may simplify this - ie.
the voiture table cannot have a num_cli that does NOT exist in poste.

The following query (UDB 8.2) will generate your results, assuming
non-matching values in both tables. T1 and t2 are your two tables and
"num" is the matching column:

with temp1 as (select num as num1,count(*) as count1
from t1 group by num),
temp2 as (select num as num2, count(*) as count2
from t2 group by num),
temp3 as ( select num1 as num from temp1
union select num2 as num from temp2)
select num
,value(count1,0) as "nombre de poste"
,coalesce(count2,0) as "nombre de voiture"
from temp3
left outer join temp1 on num = num1
left outer join temp2 on num = num2
order by num
;

source data:
insert into t1 values(1),(1),(2),(3),(3),(3),(4),(4),(5)
insert into t2 values(1),(1),(1),(3),(3),(3),(4),(5),(5),(6),(6)

results:

NUM nombre de poste nombre de voiture
----------- --------------- -----------------
1 2 3
2 1 0
3 3 3
4 2 1
5 1 2
6 0 2

6 record(s) selected.

Phil Sherman


vacataire testeur de site web wrote:
Bonjour je cherche à afficher de count de tables identiques dans la forme

exemple

num_cli | nombre de poste | nombre de voiture
1 1 3
2 2 5
3 1 0
45 4 6

deux tables poste et voitures par exemple

merci pour votre aide
thierry


Nov 12 '05 #4
Thanks I have not the time to test now but it seems really good.
Thierry

Philip Sherman <ps******@ameritech.net> wrote in message news:<hL***************@newssvr19.news.prodigy.com >...
Assuming you want to count the number of rows in each table that have
matching values for a single column (num_cli), you have the following to do:
1. get counts for each table
2. merge the results

This is complicated by the possibility of having non-matching values in
num_cli for the tables. Application data rules may simplify this - ie.
the voiture table cannot have a num_cli that does NOT exist in poste.

The following query (UDB 8.2) will generate your results, assuming
non-matching values in both tables. T1 and t2 are your two tables and
"num" is the matching column:

with temp1 as (select num as num1,count(*) as count1
from t1 group by num),
temp2 as (select num as num2, count(*) as count2
from t2 group by num),
temp3 as ( select num1 as num from temp1
union select num2 as num from temp2)
select num
,value(count1,0) as "nombre de poste"
,coalesce(count2,0) as "nombre de voiture"
from temp3
left outer join temp1 on num = num1
left outer join temp2 on num = num2
order by num
;

source data:
insert into t1 values(1),(1),(2),(3),(3),(3),(4),(4),(5)
insert into t2 values(1),(1),(1),(3),(3),(3),(4),(5),(5),(6),(6)

results:

NUM nombre de poste nombre de voiture
----------- --------------- -----------------
1 2 3
2 1 0
3 3 3
4 2 1
5 1 2
6 0 2

6 record(s) selected.

Phil Sherman


vacataire testeur de site web wrote:
Bonjour je cherche à afficher de count de tables identiques dans la forme

exemple

num_cli | nombre de poste | nombre de voiture
1 1 3
2 2 5
3 1 0
45 4 6

deux tables poste et voitures par exemple

merci pour votre aide
thierry

Nov 12 '05 #5

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

Similar topics

6
by: Raymond H. | last post by:
Bonjour, Je n'arrive pas à savoir comment lire via vb4 l'adresse d'un favoris dans le dossier des favoris où Internet Explorer place ses favoris. Par exemple, comment fait-on pour afficher l'url...
2
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit...
6
by: tfsmag | last post by:
I tried getting the record count by doing it through the ItemDataBound on the repeater with no luck... Can someone help me out here? Thanks in advance. Here is the code that sets up the data...
3
by: Hyphessobricon | last post by:
Hallo, Indeed, a count of a query with a group by function gives more records than there are and so for-next structures don't function. How is this to be mended. Anyone? Everyone in fact....
4
by: Peter W Johnson | last post by:
Hi guys, I have a problem with a datagrid record count. Here is the code:- <snip> Public Class frmMerchantDeposit Inherits System.Windows.Forms.Form Dim myconnection As New...
4
by: Chris | last post by:
Can't seem to figure out how to do this and have been reading for some time now...... I want to select a row count from a table name in SYSTABLES. This statement does not return what I needed,...
4
by: crane.jake | last post by:
Hi, I'm trying to find the following information from the table found bellow. Year_Sales - # of sales that have occurred this year Year_Income - SUM(amount) Month_Sales - # of sales that have...
2
by: leegold58 | last post by:
Newbie question must of been asked before but: How do I count the number of tables in a database? Without VB, prefer to use SQL or the Access GUI somehow. Thanks. Lee g.
1
by: kummu4help | last post by:
hi, i am using mysql. i have 3 tables with following structures. these are not actual tables i am working on. table A id varchar(16),name varchar(255),InDate datetime table B id...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.