{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Bid bbid and rsidssid rsid ssid 42 query examples

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ERE R.bid = B.bid AND R.sid=S.sid)); R.sid= S.sid)); 42 Query Examples (continued) Query Examples (continued) String comparisons: (Q18) Find ages of sailors whose last name begins and ends with B and has at least 3 characters. Can use comparison operators (=, <, >, etc.) to compare strings. SELECT FROM WHERE Can also use LIKE operator as well as wild-card symbols. % 0 or more arbitrary characters _ exactly 1 character S.age Sailors S S.sname LIKE ‘B_%B’; B_%B’ For example, ‘_AB%’ denotes a pattern matching any string containing 3 or more characters, with the second and third characters being AB. 43 43 Query Examples (continued) Query Examples (continued) (Q26) Find average age of sailors with a rating of 10. SELECT FROM WHERE (Q27) Find name and age of oldest sailor. AVG (S.age) (S.age) Sailors S S.rating = 10; Solution with syntax error: SELECT FROM (Q28) Count the number of sailors. SELECT FROM COUNT(*) Sailors; 44 S.sname, MAX(S.age) S.sname, MAX(S.age) Sailors S; Correct solution: NOTE: No blank before “(” with aggregate operators SELECT FROM WHERE (Q29) Count number of different sailor...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online