Home » SQL & PL/SQL » SQL & PL/SQL » SQL QUERY HELP
SQL QUERY HELP [message #647361] Wed, 27 January 2016 03:16 Go to next message
arifs3738
Messages: 39
Registered: November 2015
Location: India
Member
1)
From the below query i want my output to display first half in Upper & Second Half in Lower

SELECT UPPER(SUBSTR(ENAME, 1, LENGTH(ENAME)/2)) ||
       LOWER(SUBSTR(ENAME, LENGTH(ENAME)/2+1))
FROM EMP;   


Question:
If my string has 5 char like ('Bryan'), then i want the output as BRYan. Witht the above query i am getting the ouput as BRyan...Please help.

2)
From the below query if my table has 15 records i want 1st half , i.e. 8 Recrods in first table & the remaining in second table

SELECT ROWNUM, EMP.* FROM EMP WHERE ROWNUM <= (SELECT COUNT(*)/2 FROM EMP);


SELECT ROWNUM, EMP.* FROM EMP
MINUS
SELECT ROWNUM, EMP.* FROM EMP WHERE ROWNUM <= (SELECT COUNT(*)/2 FROM EMP);


But i am getting the output as First query gives me 7 recs & second query gives me 8 recs.
Re: SQL QUERY HELP [message #647362 is a reply to message #647361] Wed, 27 January 2016 03:22 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
These are school homework questions, aren't they. You need to look up all the numeric functions, such CEIL.

And if you want to get good marks, do not use "record" when you mean "row".
Re: SQL QUERY HELP [message #647363 is a reply to message #647361] Wed, 27 January 2016 03:24 Go to previous message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
I notice that you repeatedly raise topics with titles such "SQL help". This is stupid. It makes your questions effectively un-searchable. Please use proper titles if you want help in future.
Previous Topic: How to get the first less date than agiven date in sql
Next Topic: Determine Missing Route_Seq Numbers
Goto Forum:
  


Current Time: Fri Apr 26 11:48:11 CDT 2024