SQL master: Exquisite SQL statement introduction

xiaoxiao2021-03-06  41

Description: Replication table (only copy structure, source table name: a New table name: b) SQL: Select * INTO B from a where 1 <> 1 Description: Copy Table (copy data, source table name: a target table name: b) SQL: INSERT INTO B (A, B, C) SELECT D, E, F from B; Description: Display article, author and last reply time sql: select a.title, a.username, B.Adddate from table A, (Select max) adddddate from table where table.title = a.title) B Description: Outer connection query (table name 1: a table name 2: b) SQL: SELECT AA, AB, AC, BC, BD , BF from a left out join b on aa = bc Description: Schedule 5 minutes ahead reminder SQL: SELECT * FROM schedule Arranging WHERE DATEDIFF ('minute', f Start time, getdate ())> 5 Description: Two association table , Delete information in the primary table, SQL: Delete from info pen where not exists (Select * from infoBz where info.infid = infobz.infid) Description: - SQL: Select A.Num, A.Name, B.UPD_DATE, B.PREV_UPD_DATE FROM TABLE1, (SELECT X.NUM, X.UPD_DATE, Y.UPD_DATE PREV_UPD_DATE FROM (SELECT NUM, UPD_DATE, INBOUND_QTY, STOCK_ONHAND FROM TABLE2 WHERE TO_CHAR (UPD_DATE, 'YYYY / MM') = TO_CHAR ( Sysdate, 'YYYY / mm')) X, (Select Num, Upd_date, stock_onhand from table2 where to_char (upd_date, 'yyyy / mm') = to_char (to_date (to_char (sys Date, 'YYYY / mm') || '/ 01', 'YYYY / MM / DD') - 1, 'YYYY / MM')) Y, WHERE X.NUM = Y.NUM ( ) and x.inbound_qty NVL (Y.Stock_OnHand, 0) <> x.stock_onhand) B Where a.num = B.NUM Description: - SQL: Select * from studentinfo where not exists (Select * from student where studentinfo.id = student.id ) And system name = '"& strdEpartmentname &"' and professional name = '"& strprofessional"' ORDER BY Gender, Source, college entrance examination: from the database to one year of telephone charge statistics (telephone fee quota congratulatory fertilizer list Two gauges)

SQL: SELECT A. IUSERPER, A.TEL, A.Standfee, TO_CHAR (A.TELFEEDATE, 'YYYY') AS TELYEAR, SUM (Decode (to_char (a.telfeedate, 'mm'), '01', a.factration )) AS Jan, SUM (Decode (a.telfeedate, 'mm'), '02', a.factration) AS fri, sum (decode (to_char (a.telfeedate, 'mm'), '03' A.FACTRATION) AS Mar, SUM (Decode (a.telfeedate, 'mm'), '04', a.factration) AS APR, SUM (Decode (a.telfeedate, 'mm') , '05', a.factration) AS May, SUM (Decode (to_CHAR (A.TELFEEDATE, 'MM'), '06', A.FACTRATION) AS JUE, SUM (Decode (a.telfeedate, 'mm'), '07', a.factration) AS JUL, SUM (Decode (to_char (a.telfeedate, 'mm'), '08', a.factration) AS AGU, SUM (Decode (to_CHAR A.TelFeedate, 'mm'), '09', a.factration) AS SEP, SUM (Decode (a.telfeedate, 'mm'), '10', a.factration) AS OCT, SUM Decode (TO_CHAR (A.TELFEEDATE, 'MM'), '11', a.factration) AS NOV, SUM (Decode (a.telfeedate, 'mm'), '12', a.factration) AS Dec from (SELECT A. IUSERPER, A.TEL, A.Standfee, B.Telfeedate, B.Factration from Telfeestand A, TELFEE B WHERE A.TEL = B.TELFAX) a group by a.Userper, a.tel, a.standfee, to_char (a.telfeedate, 'yyyy') Description: Four Table Outline Questions: SQL: SELECT * FROM A Left inner join c on aa = cc inner Join D on aa = dd where ..... Description: Get the smallest unused ID number in the table SQL: SELECT (SELECT * From handle b where b.handleid = 1) Then min (Handleid) 1 else 1 End) AS Handleid from Handle WHERE NOT HANDLEID IN (SELECT A.HANDLEID - 1 from Handle A)

转载请注明原文地址:https://www.9cbs.com/read-77319.html

New Post(0)