View previous topic :: View next topic
|
Author |
Message |
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Hi All,
These are the interview questions i faced.
1) there is a table where there are 3 rows for each subject for a student like
Student no Student name History Physics Chemistry
001 AAA 98
001 AAA 97
001 AAA 96
like above and he need answer as Student no Student name student total
001 AAA 291
like this
i don't know how to write a query for this
2) Program A is calling Program B
my requirement is that Program B should be designed in such a way that it should act as a stand alone program and also like a calling program?
i said through Exit we can but the interviewer not correct
3) there is a table where we have to delete the yesterday rows and insert today s rows and there are millions of rows how can we design a program for this requirement.?
i told we can delete the rows by giving range and we can commit for every 10000 rows.
4) i am moving a numeric value to alphabetic when we compile the program will i get an error or when we run the jcl ?
i said while compiling but don't know what error will be thrown. |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1314 Location: Vilnius, Lithuania
|
|
|
|
anandinmainframe wrote: |
4) i am moving a numeric value to alphabetic when we compile the program will i get an error or when we run the jcl ?
i said while compiling but don't know what error will be thrown. |
The question is senseless, in REXX and PL/I you can move numerical values to character. In REXX anything is character anyway, and in PL/I the compiler will just warn you and call a library subroutine at runtime to do the move. |
|
Back to top |
|
|
Dsingh29
Active User
Joined: 16 Dec 2008 Posts: 132 Location: IBM
|
|
|
|
I think it will only throw error in case of arithmetic operations on alphabetic variable, otherwise it looks fine to me. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
Quote: |
4) i am moving a numeric value to alphabetic when we compile the program will i get an error or when we run the jcl ?
i said while compiling but don't know what error will be thrown. |
Are You sure that the question was posed in that way ?
if the masks/pictures/lengths are reasonably consistent a plain move will be happily executed in both directions
at most You might get a warning at compile time
if like in this case <alphabetic> applies to the definition - PIC X for COBOL or CHAR for PL/1
at run time the output depends on the content of the <alphabetic> field
the move will be <generally> happily executed,
the failure might happen later, on real arithmetic oprerations |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
4) i am moving a numeric value to alphabetic when we compile the program will i get an error or when we run the jcl ?
i said while compiling but don't know what error will be thrown. |
In COBOL, you cannot move a PIC 9 variable to a PIC A variable -- this causes a compile error. Moving a PIC 9 variable to a PIC X variable is perfectly legal in COBOL and is not a problem. |
|
Back to top |
|
|
Tushar Sood
New User
Joined: 26 Oct 2008 Posts: 14 Location: New Jersey
|
|
|
|
For the 1st question, i guess the following query will do -
Select Studentno, studentname,sum(marks) as TotalMarks
from studenttable
group by studentno; |
|
Back to top |
|
|
Bang_1
New User
Joined: 08 May 2009 Posts: 39 Location: Bangalore
|
|
|
|
In COBOL, data type compatability error comes during the compilation. |
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Hi All,
I have posted the same question which was asked by the Interviewer.
Tushar Sood,
AFAIK that query will not work. |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Correction:- for the 1st query
Select Studentno, studentname,sum(marks) as TotalMarks
from studenttable
group by studentno,studentname; |
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
history,physics,chemistry is different columns there was a aligning mistake so you cannot sum with different columns |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
The only mistake in alignment was you not putting code tags around your example. Code tags preserve spacing and are not just for code. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
the way the question was posed really sucks:
Code: |
Student no Student name History Physics Chemistry
001 AAA 98
001 AAA 97
001 AAA 96
|
which does not make any sense.
either you have 3 subjects per row, meaning your columns are:- Student no
- Student name
- History
- Physics
- Chemistry
and you have 1 row per student.
thus the sql would be
Code: |
select student_no
, student_name
, sum(history + physics + chemistry)
from...
order by 1,2 |
or you have a row that includes:- Student no
- Student name
- subj code
- mark
where possibly, there would be three rows per student, one for each subj and grade.
and the sql would be
Code: |
select student_no
, student_name
, grade
from...
group by student_no
, student_name
, grade
order by 1?2?
|
as Nic said, use BB code to display your design, so that someone can make sense of the topic. |
|
Back to top |
|
|
|