Home > database >  Questions about multi-table query
Questions about multi-table query

Time:10-07

Have createRole table, field has TIME, UID, rids, CID, the login field has TIME, UID, rids, CID, need statistics a few days, the number of a CID under different rids, the Angle of statistics for the number, the latter for the number of active, eventually return one day, a CID number and Angle and active, what good method is recommended to have excuse me?

CodePudding user response:

Suggest you list your table structure, and provide the test data, and based on these test data that corresponds to the correct result,
Refer to the way the post questions http://bbs.csdn.net/topics/320211382

1. You create table XXX.. Statement
2. You insert into XXX... Statement
3. The result is what kind, and give a simple algorithm description)
4. Do you use the database name and version of (often asked in MS SQL server edition MySQL)

So people who want to help you to build the same environment with you directly, and in providing the test before, avoid the error in the text understanding,

CodePudding user response:

I need to post?

CodePudding user response:

The create table create (
Time a datetime,
Cid int,
Zid int,
Uid int,
Rids int
);
Insert into the create (' 13:00:00 2017-7-10, 1000, 1, 1, 1);
Insert into the create (' 2017-7-10 14:00:00 ', 1000, 2, 1, 2);
Insert into the create (' 13:00:00 2017-7-10, 1000, 1, 2, 3);
Insert into the create (' 13:00:00 2017-7-11, 1000, 1, 3, 4);

The create table login (
Time a datetime,
Cid int,
Zid int,
Uid int,
Rids int
);
Insert into the create (' 20:00:00 2017-7-10, 1000, 1, 1, 1);
Insert into the create (' 20:10:00 2017-7-10, 1000, 1, 1, 1);
Insert into the create (' 20:20:00 2017-7-10, 1000, 2, 1, 2);
Insert into the create (' 13:00:00 2017-7-11, 1000, 1, 1, 1);
Insert into the create (' 13:00:00 2017-7-11, 1000, 1, 2, 3);

Want such result:
Time cid zid create active
The 2017-7-10 1000 1 2 1
The 2017-7-10 1000 1 2 1
The 2017-7-11 1000 1 1 1
The 2017-7-11 1000 2 0 to 1
  • Related