SELECT column-list FROM table_name [WHERE condition] [ORDER BY column1, column2, .. columnN] [ASC | DESC];
ID NAME AGE ADDRESS SALARY---------- ---------- ---------- ---------- ----------1 Paul 32 California 20000.02 Allen 25 Texas 15000.03 Teddy 23 Norway 20000.04 Mark 25 Rich-Mond 65000.05 David 27 Texas 85000.06 Kim 22 South-Hall 45000.07 James 24 Houston 10000.0
sqlite> SELECT * FROM COMPANY ORDER BY SALARY ASC;
ID NAME AGE ADDRESS SALARY---------- ---------- ---------- ---------- ----------7 James 24 Houston 10000.02 Allen 25 Texas 15000.01 Paul 32 California 20000.03 Teddy 23 Norway 20000.06 Kim 22 South-Hall 45000.04 Mark 25 Rich-Mond 65000.05 David 27 Texas 85000.0
sqlite> SELECT * FROM COMPANY ORDER BY NAME, SALARY ASC;
ID NAME AGE ADDRESS SALARY---------- ---------- ---------- ---------- ----------2 Allen 25 Texas 15000.05 David 27 Texas 85000.07 James 24 Houston 10000.06 Kim 22 South-Hall 45000.04 Mark 25 Rich-Mond 65000.01 Paul 32 California 20000.03 Teddy 23 Norway 20000.0
SELECT column-listFROM table_nameWHERE [ conditions ]GROUP BY column1, column2....columnNORDER BY column1, column2....columnN
ID NAME AGE ADDRESS SALARY---------- ---------- ---------- ---------- ----------1 Paul 32 California 20000.02 Allen 25 Texas 15000.03 Teddy 23 Norway 20000.04 Mark 25 Rich-Mond 65000.05 David 27 Texas 85000.06 Kim 22 South-Hall 45000.07 James 24 Houston 10000.0
sqlite> SELECT NAME, SUM(SALARY) FROM COMPANY GROUP BY NAME;
NAME SUM(SALARY)---------- -----------Allen 15000.0David 85000.0James 10000.0Kim 45000.0Mark 65000.0Paul 20000.0Teddy 20000.0
SELECTFROMWHEREGROUP BYHAVINGORDER BY
SELECT column1, column2FROM table1, table2WHERE [ conditions ]GROUP BY column1, column2HAVING [ conditions ]ORDER BY column1, column2
ID NAME AGE ADDRESS SALARY---------- ---------- ---------- ---------- ----------1 Paul 32 California 20000.02 Allen 25 Texas 15000.03 Teddy 23 Norway 20000.04 Mark 25 Rich-Mond 65000.05 David 27 Texas 85000.06 Kim 22 South-Hall 45000.07 James 24 Houston 10000.08 Paul 24 Houston 20000.09 James 44 Norway 5000.010 James 45 Texas 5000.0
sqlite> SELECT * FROM COMPANY GROUP BY name HAVING count(name) < 2;
ID NAME AGE ADDRESS SALARY---------- ---------- ---------- ---------- ----------2 Allen 25 Texas 150005 David 27 Texas 850006 Kim 22 South-Hall 450004 Mark 25 Rich-Mond 650003 Teddy 23 Norway 20000
Nguồn tin: vncoder.vn
Những tin mới hơn
Những tin cũ hơn
- Click vào nút hiển thị ngày trong tuần hoặc tháng âm lịch để xem chi tiết
- Màu đỏ: Ngày tốt
- Xanh lá: Đầu tháng âm lịch
- Màu vàng: Ngày hiện tại