我的数据库中有这三个表,我想从三个表中选择共同的日期来计算每天的利润,每月的利润和每年的利润
这是我的桌子:
Schema::create('expenses', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->float('amount');
$table->string('month');
$table->string('year');
$table->string('date');
});
Schema::create('service_orders', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('client_id')->unsigned();
$table->double('total_price', 8, 2)->nullable();
$table->string('month');
$table->string('year');
$table->date('date');
$table
->foreign('client_id')
->references('id')
->on('clients')
->onDelete('cascade');
});
Schema::create('orders', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('client_id')->unsigned();
$table->double('total_price', 8, 2)->nullable();
$table->string('month');
$table->string('year');
$table->date('date');
$table
->foreign('client_id')
->references('id')
->on('clients')
->onDelete('cascade');
});