Home » SQL & PL/SQL » SQL & PL/SQL » Format a query
Format a query [message #245071] Fri, 15 June 2007 02:03 Go to next message
u263066
Messages: 47
Registered: March 2007
Member
I have data as

  EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM 	dept

   7566 JONES      MANAGER         7839 02-APR-81       2975     	 	20
   7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400      	30
   7698 BLAKE      MANAGER         7839 01-MAY-81       2850		     	30
   7782 CLARK      MANAGER         7839 09-JUN-81       2450			10
   7654 MARTIN     SALESMAN        7698 28-SEP-81       1250             	30
   7782 CLARK      MANAGER         7839 09-JUN-81       2450			40
   7782 CLARK      MANAGER         7839 09-JUN-81       2450			10


Is there any way that I can get data in this way by a simple sql functions
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM 	dept
   
      7698 BLAKE      MANAGER         7839 01-MAY-81       2850		     	30
      7782 CLARK      MANAGER         7839 09-JUN-81       2450			40
      		                           19-JUN-81       2450			10
      		              		   29-JUN-81       2450			10
      7566 JONES      MANAGER         7839 02-APR-81       2975     	 	20
      7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400      30
                    			   29-SEP-81       1254             	30
Re: Format a query [message #245078 is a reply to message #245071] Fri, 15 June 2007 02:18 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
If you explain why there are blanks instead of data in some columns maybe we can give you a solution.

Regards
Michel
Re: Format a query [message #245087 is a reply to message #245078] Fri, 15 June 2007 02:30 Go to previous messageGo to next message
u263066
Messages: 47
Registered: March 2007
Member
Few columns are repeated so, want to display the first line with details and then rest of line of few columns only.

it is bit easy to do by cursor,and is there any way by simple sql where the first line print all records and rest of the lines.

any input sir
Re: Format a query [message #245089 is a reply to message #245087] Fri, 15 June 2007 02:34 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
When you repeat, when you don't repeat, what are the rules?
This is the only question.

Regards
Michel
Re: Format a query [message #245091 is a reply to message #245089] Fri, 15 June 2007 02:40 Go to previous messageGo to next message
u263066
Messages: 47
Registered: March 2007
Member
Based out of above example, for Repeat the rule is :
EMPNO,ENAME,JOB,MGR will remain same.
for change
any of these HIREDATE,SAL,COMM,dept will have different values.


Re: Format a query [message #245093 is a reply to message #245091] Fri, 15 June 2007 02:42 Go to previous messageGo to next message
u263066
Messages: 47
Registered: March 2007
Member
is something we can achieve by union and query in RollUp

any input


Re: Format a query [message #245106 is a reply to message #245091] Fri, 15 June 2007 03:29 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
Based out of above example

An example is not a rule.
I can find hundred of rules to fit the same output with your examples.

Have a look at BREAK command.

Regards
Michel


Re: Format a query [message #245161 is a reply to message #245106] Fri, 15 June 2007 06:07 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
"Based out of above example", we have to make up hiredates.

09-JUN-81 mysteriously becomes 19-JUN-81 and 29-JUN-81, whereas 28-SEP-81 becomes 29-SEP-81

[Updated on: Fri, 15 June 2007 06:09]

Report message to a moderator

Re: Format a query [message #245191 is a reply to message #245161] Fri, 15 June 2007 07:28 Go to previous message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Laughing
Previous Topic: cursors
Next Topic: NOT URGENT - do not answer. Please help PLS -00306
Goto Forum:
  


Current Time: Mon Dec 05 13:05:50 CST 2016

Total time taken to generate the page: 0.09793 seconds