


SELECT name, class, CDOW(dob) AS bdate FROM student WHERE DOW(dob) IN (4,7) name class bdate Result Peter 1A Wednesday Wendy 1B Wednesday Kevin 1C Saturday Luke 1A Wednesday Aaron 1A Saturday : : : 6 Comparison List the students who were born on Wednesday or Saturdays. II Comparison expr IN ( value1, value2, value3) expr BETWEEN value1 AND value2 expr LIKE "%_" SELECT name, id, class FROM student WHERE class="1A" AND NOT remission name id class Result Peter 9801 1A Mary 9802 1A Luke 9810 1A Bobby 9811 1A Aaron 9812 1A Ron 9813 1A Gigi 9824 1A : : : 5 General Structure List the names, id of 1A students with no fee remission. SELECT name, ROUND((DATE( )-dob)/365,1) AS age FROM student WHERE class="1B" AND sex="F" Result name age Wendy 12.1 Kitty 11.5 Janet 12.4 Sandy 12.3 Mimi 12.2 4 General Structure List the names and ages (1 d.p.) of 1B girls. Functions: # days : DATE( ) – dob # years :(DATE( ) – dob) / 365 1 d.p.: ROUND(_, 1) Condition for "1B Girls": 1) class = "1B" 2) sex = "F" 3) Both ( AND operator) SELECT DISTINCT dcode FROM student WHERE hcode="R" dcode Result HHM KWC MKK SSP TST YMT 3 General Structure List the residential district of the Red House members. Result name hcode class Peter R 1A Mary Y 1A Johnny G 1A Luke G 1A Bobby B 1A Aaron R 1A : : :
Sql plus download free code#
2 General Structure List the names and house code of 1A students. SELECT name, hcode, class FROM student WHERE class="1A" Class Class 1A 1A class="1A" 1A 1A 1A 1A 1B 1B 1B 1B : :

SELECT * FROM student id name dob sex class mtest hcode dcode remissionResult 9801 Peter 06/04/86 M 1A 70 R SSP. I General Structure Before using SQL, open the student file: USE student eg. I General Structure SELECT expr1, expr2 FROM tablename WHERE condition – DISTINCT will eliminate duplication in the output while ALL will keep all duplicated rows.– condition can be : – And col1, col2 are their corresponding column names in the output table.
Sql plus download free how to#
(instead of algorithms)ġ Introduction to SQL Concept of SQL– The user specifies a certain condition.– The program will go through all the records in the database file and select those records that satisfy the condition.(searching).– Statistical information of the data.– The result of the query will then be stored in form of a table.ġ Introduction to SQL How to involve SQL in FoxPro – Before using SQL, the tables should be opened. – SQL is a query language that allows user to specify the conditions. – A query is a user–request to retrieve data or information with a certain condition. 1 Introduction to SQL What is SQL? – When a user wants to get some information from a database file, he can issue a query.
