Sunday, August 15, 2010
Oracle 11g: Using Character-Manipulation Functions
select employee_id,
first_name,
last_name
job_id
from employees
Results
EMPLOYEE_ID FIRST_NAME JOB_ID
---------------------- -------------------- -------------------------
100 Steven King
101 Neena Kochhar
102 Lex De Haan
103 Alexander Hunold
104 Bruce Ernst
105 David Austin
106 Valli Pataballa
107 Diana Lorentz
108 Nancy Greenberg
109 Daniel Faviet
110 John Chen
111 Ismael Sciarra
112 Jose Manuel Urman
113 Luis Popp
114 Den Raphaely
115 Alexander Khoo
116 Shelli Baida
117 Sigal Tobias
118 Guy Himuro
119 Karen Colmenares
120 Matthew Weiss
121 Adam Fripp
122 Payam Kaufling
123 Shanta Vollman
124 Kevin Mourgos
125 Julia Nayer
126 Irene Mikkilineni
127 James Landry
128 Steven Markle
129 Laura Bissot
130 Mozhe Atkinson
131 James Marlow
132 TJ Olson
133 Jason Mallin
134 Michael Rogers
135 Ki Gee
136 Hazel Philtanker
137 Renske Ladwig
138 Stephen Stiles
139 John Seo
140 Joshua Patel
141 Trenna Rajs
142 Curtis Davies
143 Randall Matos
144 Peter Vargas
145 John Russell
146 Karen Partners
147 Alberto Errazuriz
148 Gerald Cambrault
149 Eleni Zlotkey
150 Peter Tucker
151 David Bernstein
152 Peter Hall
153 Christopher Olsen
154 Nanette Cambrault
155 Oliver Tuvault
156 Janette King
157 Patrick Sully
158 Allan McEwen
159 Lindsey Smith
160 Louise Doran
161 Sarath Sewall
162 Clara Vishney
163 Danielle Greene
164 Mattea Marvins
165 David Lee
166 Sundar Ande
167 Amit Banda
168 Lisa Ozer
169 Harrison Bloom
170 Tayler Fox
171 William Smith
172 Elizabeth Bates
173 Sundita Kumar
174 Ellen Abel
175 Alyssa Hutton
176 Jonathon Taylor
177 Jack Livingston
178 Kimberely Grant
179 Charles Johnson
180 Winston Taylor
181 Jean Fleaur
182 Martha Sullivan
183 Girard Geoni
184 Nandita Sarchand
185 Alexis Bull
186 Julia Dellinger
187 Anthony Cabrio
188 Kelly Chung
189 Jennifer Dilly
190 Timothy Gates
191 Randall Perkins
192 Sarah Bell
193 Britney Everett
194 Samuel McCain
195 Vance Jones
196 Alana Walsh
197 Kevin Feeney
198 Donald OConnell
199 Douglas Grant
200 Jennifer Whalen
201 Michael Hartstein
202 Pat Fay
203 Susan Mavris
204 Hermann Baer
205 Shelley Higgins
206 William Gietz
107 rows selected
===> SQL Query using characters-manipulation functions
select employee_id,
CONCAT(first_name, last_name) EMPLOYEENAME,
job_id,
LENGTH(last_name),
INSTR(last_name,'a') "Contains 'a'?"
from employees
where SUBSTR(job_id, 4)='REP'
Results
EMPLOYEE_ID EMPLOYEENAME JOB_ID LENGTH(LAST_NAME) Contains 'a'?
---------------------- --------------------------------------------- ---------- --------
150 PeterTucker SA_REP 6 0
151 DavidBernstein SA_REP 9 0
152 PeterHall SA_REP 4 2
153 ChristopherOlsen SA_REP 5 0
154 NanetteCambrault SA_REP 9 2
155 OliverTuvault SA_REP 7 4
156 JanetteKing SA_REP 4 0
157 PatrickSully SA_REP 5 0
158 AllanMcEwen SA_REP 6 0
159 LindseySmith SA_REP 5 0
160 LouiseDoran SA_REP 5 4
161 SarathSewall SA_REP 6 4
162 ClaraVishney SA_REP 7 0
163 DanielleGreene SA_REP 6 0
164 MatteaMarvins SA_REP 7 2
165 DavidLee SA_REP 3 0
166 SundarAnde SA_REP 4 0
167 AmitBanda SA_REP 5 2
168 LisaOzer SA_REP 4 0
169 HarrisonBloom SA_REP 5 0
170 TaylerFox SA_REP 3 0
171 WilliamSmith SA_REP 5 0
172 ElizabethBates SA_REP 5 2
173 SunditaKumar SA_REP 5 4
174 EllenAbel SA_REP 4 0
175 AlyssaHutton SA_REP 6 0
176 JonathonTaylor SA_REP 6 2
177 JackLivingston SA_REP 10 0
178 KimberelyGrant SA_REP 5 3
179 CharlesJohnson SA_REP 7 0
202 PatFay MK_REP 3 2
203 SusanMavris HR_REP 6 2
204 HermannBaer PR_REP 4 2
33 rows selected
first_name,
last_name
job_id
from employees
Results
EMPLOYEE_ID FIRST_NAME JOB_ID
---------------------- -------------------- -------------------------
100 Steven King
101 Neena Kochhar
102 Lex De Haan
103 Alexander Hunold
104 Bruce Ernst
105 David Austin
106 Valli Pataballa
107 Diana Lorentz
108 Nancy Greenberg
109 Daniel Faviet
110 John Chen
111 Ismael Sciarra
112 Jose Manuel Urman
113 Luis Popp
114 Den Raphaely
115 Alexander Khoo
116 Shelli Baida
117 Sigal Tobias
118 Guy Himuro
119 Karen Colmenares
120 Matthew Weiss
121 Adam Fripp
122 Payam Kaufling
123 Shanta Vollman
124 Kevin Mourgos
125 Julia Nayer
126 Irene Mikkilineni
127 James Landry
128 Steven Markle
129 Laura Bissot
130 Mozhe Atkinson
131 James Marlow
132 TJ Olson
133 Jason Mallin
134 Michael Rogers
135 Ki Gee
136 Hazel Philtanker
137 Renske Ladwig
138 Stephen Stiles
139 John Seo
140 Joshua Patel
141 Trenna Rajs
142 Curtis Davies
143 Randall Matos
144 Peter Vargas
145 John Russell
146 Karen Partners
147 Alberto Errazuriz
148 Gerald Cambrault
149 Eleni Zlotkey
150 Peter Tucker
151 David Bernstein
152 Peter Hall
153 Christopher Olsen
154 Nanette Cambrault
155 Oliver Tuvault
156 Janette King
157 Patrick Sully
158 Allan McEwen
159 Lindsey Smith
160 Louise Doran
161 Sarath Sewall
162 Clara Vishney
163 Danielle Greene
164 Mattea Marvins
165 David Lee
166 Sundar Ande
167 Amit Banda
168 Lisa Ozer
169 Harrison Bloom
170 Tayler Fox
171 William Smith
172 Elizabeth Bates
173 Sundita Kumar
174 Ellen Abel
175 Alyssa Hutton
176 Jonathon Taylor
177 Jack Livingston
178 Kimberely Grant
179 Charles Johnson
180 Winston Taylor
181 Jean Fleaur
182 Martha Sullivan
183 Girard Geoni
184 Nandita Sarchand
185 Alexis Bull
186 Julia Dellinger
187 Anthony Cabrio
188 Kelly Chung
189 Jennifer Dilly
190 Timothy Gates
191 Randall Perkins
192 Sarah Bell
193 Britney Everett
194 Samuel McCain
195 Vance Jones
196 Alana Walsh
197 Kevin Feeney
198 Donald OConnell
199 Douglas Grant
200 Jennifer Whalen
201 Michael Hartstein
202 Pat Fay
203 Susan Mavris
204 Hermann Baer
205 Shelley Higgins
206 William Gietz
107 rows selected
===> SQL Query using characters-manipulation functions
select employee_id,
CONCAT(first_name, last_name) EMPLOYEENAME,
job_id,
LENGTH(last_name),
INSTR(last_name,'a') "Contains 'a'?"
from employees
where SUBSTR(job_id, 4)='REP'
Results
EMPLOYEE_ID EMPLOYEENAME JOB_ID LENGTH(LAST_NAME) Contains 'a'?
---------------------- --------------------------------------------- ---------- --------
150 PeterTucker SA_REP 6 0
151 DavidBernstein SA_REP 9 0
152 PeterHall SA_REP 4 2
153 ChristopherOlsen SA_REP 5 0
154 NanetteCambrault SA_REP 9 2
155 OliverTuvault SA_REP 7 4
156 JanetteKing SA_REP 4 0
157 PatrickSully SA_REP 5 0
158 AllanMcEwen SA_REP 6 0
159 LindseySmith SA_REP 5 0
160 LouiseDoran SA_REP 5 4
161 SarathSewall SA_REP 6 4
162 ClaraVishney SA_REP 7 0
163 DanielleGreene SA_REP 6 0
164 MatteaMarvins SA_REP 7 2
165 DavidLee SA_REP 3 0
166 SundarAnde SA_REP 4 0
167 AmitBanda SA_REP 5 2
168 LisaOzer SA_REP 4 0
169 HarrisonBloom SA_REP 5 0
170 TaylerFox SA_REP 3 0
171 WilliamSmith SA_REP 5 0
172 ElizabethBates SA_REP 5 2
173 SunditaKumar SA_REP 5 4
174 EllenAbel SA_REP 4 0
175 AlyssaHutton SA_REP 6 0
176 JonathonTaylor SA_REP 6 2
177 JackLivingston SA_REP 10 0
178 KimberelyGrant SA_REP 5 3
179 CharlesJohnson SA_REP 7 0
202 PatFay MK_REP 3 2
203 SusanMavris HR_REP 6 2
204 HermannBaer PR_REP 4 2
33 rows selected
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment