SQL Plus Question
Page 1 of 18 Replies - 9812 Views - Last Post: 21 July 2006 - 01:11 PM
#1
SQL Plus Question
Posted 18 July 2006 - 04:07 PM
Format columns as follows: STUDENT_ID column with FORMAT 99; PHONE with FORMAT xxx-xxx-xxxx; REGISTRATION_DATE with FORMAT MM-DD-YYYY. Show all SQL*PLUS statements used and all outputs.
Can someone tell me what I need to do?
THANKS
Replies To: SQL Plus Question
#2
Re: SQL Plus Question
Posted 18 July 2006 - 06:47 PM
http://www.psoug.org...ce/sqlplus.html
http://www.ss64.com/...x/plus_fmt.html
#3
Re: SQL Plus Question
Posted 19 July 2006 - 07:18 AM
Amadeus, on 18 Jul, 2006 - 05:39 PM, said:
http://www.psoug.org...ce/sqlplus.html
http://www.ss64.com/...x/plus_fmt.html
So would I enter the column format as:
COLUMN REGISTRATION_DATE FORMAT MM-DD-YYYY
If this is not correct how would I enter this command?
THANKS
#4
Re: SQL Plus Question
Posted 19 July 2006 - 08:08 AM
Use this CREATE TABLE <table name>(column_name <type>, ...);
And you can't use the LONG type for the phone...you have to treat it as a string.
#5
Re: SQL Plus Question
Posted 19 July 2006 - 07:12 PM
#6
Re: SQL Plus Question
Posted 19 July 2006 - 08:46 PM
cswtsjaij, on 19 Jul, 2006 - 06:10 AM, said:
COLUMN REGISTRATION_DATE FORMAT MM-DD-YYYY
If this is not correct how would I enter this command?
THANKS
To format the date in that type of format requires two steps:
First for the column itself you are just going to specify the column width.
COLUMN REGISTRATION_DATE FORMAT A10
Then to get the date in the correct format, use the TO_CHAR(someColumn, 'MM-DD-YYYY') inside your SQL statement.
For example:
SELECT TO_CHAR(someColumn, 'MM-DD-YYYY') "Date" FROM yourTable
This will return a date in the format you need. Just replace someColumn with the name of the correct column and "Date" is an alias, so you can make it whatever you need it say.
#7
Re: SQL Plus Question
Posted 20 July 2006 - 09:11 AM
jayman9, on 19 Jul, 2006 - 07:38 PM, said:
cswtsjaij, on 19 Jul, 2006 - 06:10 AM, said:
COLUMN REGISTRATION_DATE FORMAT MM-DD-YYYY
If this is not correct how would I enter this command?
THANKS
To format the date in that type of format requires two steps:
First for the column itself you are just going to specify the column width.
COLUMN REGISTRATION_DATE FORMAT A10
Then to get the date in the correct format, use the TO_CHAR(someColumn, 'MM-DD-YYYY') inside your SQL statement.
For example:
SELECT TO_CHAR(someColumn, 'MM-DD-YYYY') "Date" FROM yourTable
This will return a date in the format you need. Just replace someColumn with the name of the correct column and "Date" is an alias, so you can make it whatever you need it say.
Thank you for your help I greatly appreciate it.
#8
Re: SQL Plus Question
Posted 21 July 2006 - 08:18 AM
jayman9, on 19 Jul, 2006 - 07:38 PM, said:
cswtsjaij, on 19 Jul, 2006 - 06:10 AM, said:
COLUMN REGISTRATION_DATE FORMAT MM-DD-YYYY
If this is not correct how would I enter this command?
THANKS
To format the date in that type of format requires two steps:
First for the column itself you are just going to specify the column width.
COLUMN REGISTRATION_DATE FORMAT A10
Then to get the date in the correct format, use the TO_CHAR(someColumn, 'MM-DD-YYYY') inside your SQL statement.
For example:
SELECT TO_CHAR(someColumn, 'MM-DD-YYYY') "Date" FROM yourTable
This will return a date in the format you need. Just replace someColumn with the name of the correct column and "Date" is an alias, so you can make it whatever you need it say.
Display the results as follows: (SHOW THE OUTPUT). Include a header, with the title: Registration Date Report. Display the columns in the following order: STUDENT_ID,PHONE, then REGISTRATION_DATE column in the result set.
I am not sure what I am to do with this problem. Is it asking to add a header and display just the column titles? Or is it asking to add a header and display the columns and all data that falls under these columns? Is there a way to display just the column titles?
#9
Re: SQL Plus Question
Posted 21 July 2006 - 01:11 PM
cswtsjaij, on 21 Jul, 2006 - 07:10 AM, said:
I am not sure what I am to do with this problem. Is it asking to add a header and display just the column titles? Or is it asking to add a header and display the columns and all data that falls under these columns? Is there a way to display just the column titles?
It is saying that you will create a header title using TTITLE. And your display of the returned results will be displayed with the columns in that specific order.
For example:
SELECT STUDENT_ID, PHONE, REGISTRATION_DATE FROM STUDENTTABLE
Would return:
STUDENT_ID PHONE REGISTRATION_DATE ---------- ----- -----------------
The order that your column names are in inside the SELECT statement determines the order of the columns in the returned results.
|
|

New Topic/Question
Reply




MultiQuote




|