Home > database > MySQL custom in the quarter, and the data accumulation
MySQL custom in the quarter, and the data accumulation
Time:01-15
Single table query get out a patient data for at least two stores to buy, do not satisfy all out Table fields: Name of pharmacy to buy medicine pharmacy coding time in the name of the drug specifications purchase quantity prescription pharmacy pharmacy provinces city hospital patient number (random) belonging to a pharmacy
Query full table query is as follows: SELECT CDD SELLER_CODE AS 'sellerCode, CDD SELLER_NAME AS 'sellerName, CDD ORDER_TIME AS 'orderTime, QUARTER (CDD) ORDER_TIME) AS 'yearQuarter, CDD MED_NAME AS 'medName, CDD. SPEC AS 'SPEC', CDD AMOUNT AS 'AMOUNT', CDD PROVINCE_NAME AS 'provinceName, CDD CITY_NAME AS 'cityName, CDD. At the AS 'at' CDD PATIENT_CODE AS 'patientCode, CDD. SELLER_CODE AS 'lastSellerCode' The FROM CDD yiyao_b2c. Cmd_desensitization_data
Excuse me each big, how to write: And each user is the last time the ownership of the pharmacy to buy medicine pharmacy
CodePudding user response:
SELECT * The FROM yiyao_b2c. Cmd_desensitization_data CDD WHERE the EXISTS (SELECT 1 FROM yiyao_b2c. Cmd_desensitization_data WHERE CDD. Pharmacy coding & lt; & gt; Pharmacy coding AND CDD. Patient number=the patient number)
CodePudding user response:
Thank you very much for bosses Trouble under the ask you, check out all data belonging to a pharmacy query for the last order sellerCode (store coding)