Home > database >  Two unrelated SQL table count
Two unrelated SQL table count

Time:10-08

A table: a1, time1
Table B: time2

I want to get the result: time2, all time1 & lt; The number of=time2 a1

CodePudding user response:

Is time less than the time of all time2 time1?

Select count (a1) from a
Where time1 & lt;=(select min (time2) from b);

CodePudding user response:

A table should be: type1 and type2, a1, time1
Table B: time2
Get the result: type1 and type2, time2, time1 & lt;=time2 and type1=a.t ype1 and type2=a.t ype2 by the number of a1

CodePudding user response:

reference 1st floor js14982 response:
is the time less than the time of all time2 time1?

Select count (a1) from a
Where time1 & lt;=(select min (time2) from b);

I need to put the time2 also displayed

CodePudding user response:

Such as time2 is' 2019-10-06 'is going to take A table all time1 all before the end of the 2019-10-06 a1 to count

CodePudding user response:

Select a t1. *, t2 *, count (distinct t1. A1) over (partition by t1. Time1)
The from tab1 t1, tab2 t2
Where a t1. Time1 & lt;=t2. Time2
And t1. Type1=t2. Type1
And t1. Type2=t2. Type2

CodePudding user response:

The
refer to the original poster Galahad. W response:
: A table a1, time1
Table B: time2

I want to get the result: time2, all time1 & lt; Number of=time2 a1


1,
The select b.t ime2, count (1) a.a
From a, b
Where a.t ime1 & lt;=b.t ime2
Group by b.t ime2;

2, total felling the statistics of the building Lord not too big significance,
  • Related