473,811 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1557
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.goo glegroups.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.custom er)...from t1,t2

and having in result

num count(t1.car) count(t2.custom er)
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(count 2,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******@ameri tech.net> wrote in message news:<hL******* ********@newssv r19.news.prodig y.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(count 2,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
5380
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 d'un favoris dans un msgbox? Raymond H. logicipc@sympatico.ca
2
3314
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 the selected lie item at which case I would pop up a separate dialog box to do so, in the debugging code, the dataview.count would return 0. I get a error message because I tried to get values out of a dataview that holds 0 items. Does anyone...
6
2807
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 relation (it works fine) ------------------------------------------------ private void getlinks() {
3
1667
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. Answers are greatly appreciated. -- mvg Hyphessobrycon
4
3094
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 Odbc.OdbcConnection("DSN=database")
4
7205
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, but can help explain what I'm looking for. I want the results to be the Row Count from a Table Name out of the Sub-Select. Select Count(*) from
4
5950
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 occurred this month Month_Income - SUM(amount) Today_Sales -- # of sales that have occurred today Today_Icome - SUM(amount)
2
23201
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
3809
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 varchar(16),name varchar(255),InDate datetime table C
0
9728
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
9605
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
10389
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
10402
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9205
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5554
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...
1
4339
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
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3018
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.