Jump to content

SQL query help


Recommended Posts

Posted

Hello sql gurus. Can you please help me with building a query. 
tables:

employee(empid, fname, lname)

manager(empid, managerid, deptid)

Director(empid, dirid,...)

now I would like to get results as 

empfname, emplname, ismanager, isdirector

how do I get that ? 

Posted
SELECT
Field1, Field2, Field3
FROM Table1
UNION
SELECT
Field1, Field2, Field3
FROM Table2
UNION
SELECT
Field1, Field2, Field3
FROM Table3

 

grammar.gif

  • Haha 2
Posted
6 minutes ago, usauae said:

Hello sql gurus. Can you please help me with building a query. 
tables:

employee(empid, fname, lname)

manager(empid, managerid, deptid)

Director(empid, dirid,...)

now I would like to get results as 

empfname, emplname, ismanager, isdirector

how do I get that ? 

select e.fname,e.lname,m.managerid,d.dirid from employee e, manager m,Director d where e.empid=m.empid and m.empid=d.epid

jst tried ready to crrct if missng long time tried sql

Posted
1 minute ago, Spartan said:

SELECT
Field1, Field2, Field3
FROM Table1
UNION
SELECT
Field1, Field2, Field3
FROM Table2
UNION
SELECT
Field1, Field2, Field3
FROM Table3

 

grammar.gif

BRAHMANANDAM GIFS -

 

 

Posted
4 minutes ago, Spartan said:

SELECT
Field1, Field2, Field3
FROM Table1
UNION
SELECT
Field1, Field2, Field3
FROM Table2
UNION
SELECT
Field1, Field2, Field3
FROM Table3

 

grammar.gif

harish%20rao.gif

Posted
11 minutes ago, usauae said:

Hello sql gurus. Can you please help me with building a query. 
tables:

employee(empid, fname, lname)

manager(empid, managerid, deptid)

Director(empid, dirid,...)

now I would like to get results as 

empfname, emplname, ismanager, isdirector

how do I get that ? 

select 

e.empfname, e.emplname, m.ismanager, d.isdirector

from

employee e

left join manager m on

e.empid = m.empid

left join director d on

e.empid = d.empid

Posted
8 minutes ago, naughty15 said:

select distinct a.fname, a.lname,

case when m.empid is null then 0 else 1 end as IsManager,

case when d.empid is null then 0 else 1 end as IsDirector

from employee a left outer join manager m on a.empid=m.empid left outer join director d on a.empid=d.empid

 

NOTe: NOT TESTED

Super bro it worked. 
case statement ila kuda use chesukovachhu ani teleyaledu.

inkoka help if you don’t mind. Ee query tho I get

empid1, 0,0

empid2, 1,0

so can I apply a filter to not show 0?

Posted
Just now, usauae said:

Super bro it worked. 
case statement ila kuda use chesukovachhu ani teleyaledu.

inkoka help if you don’t mind. Ee query tho I get

empid1, 0,0

empid2, 1,0

so can I apply a filter to not show 0?

CITI_c$y ni alpasantosham thagaleyya... 

  • Haha 1
Posted
1 minute ago, usauae said:

Super bro it worked. 
case statement ila kuda use chesukovachhu ani teleyaledu.

inkoka help if you don’t mind. Ee query tho I get

empid1, 0,0

empid2, 1,0

so can I apply a filter to not show 0?

CTE use chesi apply or nested SQL use chesi apply cheyacchu.

 

Posted
Just now, RajNeethi said:

CITI_c$y ni alpasantosham thagaleyya... 

encourage man... he might he tope in other techs.

if I write hello world in Python I would feel so happy.

  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...