Home > database >  Query the company 12 months of the year the plan to fill in data of each month, if a month without t
Query the company 12 months of the year the plan to fill in data of each month, if a month without t

Time:11-01

For the great god help, now there is a problem of SQL
The SELECT CUST_CODE, CUST_NAME FROM CUST_CORP_INFO
Above is the query name and number
SELECT * FROM (SELECT to_char (2010 + floor (13) (rownum)/YY, substr (' 0 '| | to_char (mod) (rownum, 13), 2, 2) MM FROM DUAL CONNECT BY rownum='00'This is me to write a query empty table is to show a year 12 months of data, the DUAL is an empty table

Known CUST_CORP_INFO have monthly data in the table, and now want to associate two tables, if the company has a month plan provided, display data, if not a month, only shows the years, the company name, company number,
XXX company, for example, in 2019 August 1 - all data provided by means of this plan, display the data, also have no, in September, only show in September 2019 and the company's name and number, the other fields empty,
Pray god help!

CodePudding user response:

Then in accordance with the extent of the date of each line, to find the company table in the corresponding data bai, date and company as a cartesian corpora

CodePudding user response:

Right, now mainly, if not fill in any month plan it this month's data only show the customer name and number, the other is empty, the data is not in the database

CodePudding user response:

Ask everybody to help! Help to do something

CodePudding user response:

About the meaning, specific tables and fields to see the building actual situation
 SELECT * 
The FROM (SELECT * FROM date table, table) t
LEFT the JOIN table
ON t.Y Lin Y=data tables. YY
AND t.M M=data tables. MM
AND t. company ID=data tables. ID;

CodePudding user response:

references on February 16, 4/f response:
about this meaning, specific tables and fields to see the building actual situation
 SELECT * 
The FROM (SELECT * FROM date table, table) t
LEFT the JOIN table
ON t.Y Lin Y=data tables. YY
AND t.M M=data tables. MM
AND t. company ID=data tables. ID;


This isn't quite right.

CodePudding user response:

4th floor statement right, LEFT to JOIN, direct query recordset,
Front desk display, read the record is empty, it is good to show a hanky-panky,
  • Related