Home » SQL & PL/SQL » SQL & PL/SQL » Need help to write query and Help to write SQL (2 threads merged by bb)
Need help to write query and Help to write SQL (2 threads merged by bb) [message #362317] Mon, 01 December 2008 15:00 Go to next message
AHBJAG
Messages: 2
Registered: December 2008
Junior Member
I have following two tables..

TableA

TIMECARD_ID STAFF_ID TIMECARD_PERIOD_ID
17924405 XYZ01 16822218
17926980 XYZ01 16822219
18157933 XYZ01 16822220
18168660 XYZ01 16822221
18394647 XYZ01 16822222
18618683 XYZ01 16822223
18844787 XYZ01 16822224
19072497 XYZ01 16822225
19301059 XYZ01 16822226
19748383 XYZ01 16822227
19973216 XYZ01 16822228
19986552 XYZ01 16822229
20544786 XYZ01 16822230

TableB

STAFF_ID TIMECARD_PERIOD_ID HR_PCT SUPERVISOR_ID BUREAU_ID
XYZ01 16822218 100 SUP01 17922782
XYZ01 16822222 75 SUP01 17922782
XYZ01 16822228 90 SUP02 17922782


I have to display something like this


TIMECARD_ID STAFF_ID TIMECARD_PERIOD_ID SUPERVISOR_ID HR_PCT
17924405 XYZ01 16822218 SUP01 100
17926980 XYZ01 16822219 SUP01 100
18157933 XYZ01 16822220 SUP01 100
18168660 XYZ01 16822221 SUP01 100
18394647 XYZ01 16822222 SUP01 75
18618683 XYZ01 16822223 SUP01 75
18844787 XYZ01 16822224 SUP01 75
19072497 XYZ01 16822225 SUP01 75
19301059 XYZ01 16822226 SUP01 75
19748383 XYZ01 16822227 SUP01 75
19973216 XYZ01 16822228 SUP02 90
19986552 XYZ01 16822229 SUP02 90
20544786 XYZ01 16822230 SUP02 90

Please help me to write this Query.

Re: Need help to write query [message #362319 is a reply to message #362317] Mon, 01 December 2008 15:08 Go to previous messageGo to next message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Post a test case: create table and insert statements along with the result you want with these data.

Explain what you want WITH WORDS not just an ouput.

Regards
Michel
Re: Need help to write query [message #362320 is a reply to message #362317] Mon, 01 December 2008 15:11 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
OUTER JOIN and possible LEAD/LAG
Help to write SQL [message #362324 is a reply to message #362317] Mon, 01 December 2008 15:32 Go to previous messageGo to next message
AHBJAG
Messages: 2
Registered: December 2008
Junior Member
Please Help me to write Sql query. I've attached the info.
  • Attachment: testot.txt
    (Size: 5.45KB, Downloaded 744 times)
Re: Help to write SQL [message #362364 is a reply to message #362324] Tue, 02 December 2008 00:57 Go to previous message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Did you check and try what joy_division mentioned?

Regards
Michel
Previous Topic: maximum value of 3 columns as new column
Next Topic: Cursor
Goto Forum:
  


Current Time: Tue Dec 03 11:01:23 CST 2024