Jump to content

SQL query help


Recommended Posts

Posted
16 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
,case when e.empid in (select managerid from manager) Then 1 Else 0 end as ismanager
,case when e.empid in (select dirid from director) Then 1 Else 0 end as isdirector
FROM employee e

Posted
14 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

you tripled the dataset just like stocks

Posted
1 minute ago, yemdoing said:

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

 

Cte ante interview ki oka line prepare avvadam tappa yeppudu use cheyyaledu 😔

Posted
1 minute ago, usauae said:

Cte ante interview ki oka line prepare avvadam tappa yeppudu use cheyyaledu 😔

jai google talli 

 

Posted
2 minutes ago, usauae said:

Cte ante interview ki oka line prepare avvadam tappa yeppudu use cheyyaledu 😔

evado aa table structure ichinodu vadiki 🙏

Posted
3 minutes ago, Picheshwar said:

you tripled the dataset just like stocks

sSa_j@il  Db lu anta padavu manaki....deploy and config ye... no data extraction

Posted
8 minutes 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?

sure you can do..two ways can be done..but let's go with this..

select * from (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) aa

where ismanager!=0  ....

do whatever required for u...

Posted
10 minutes ago, naughty15 said:

sure you can do..two ways can be done..but let's go with this..

select * from (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) aa

where ismanager!=0  ....

do whatever required for u...

Chi chi inta chinna logic kuda raaledu naaku. Thanks again bro

Posted
Just now, usauae said:

Chi chi inta chinna logic kuda raaledu naaku. Thanks again bro

think_ww

Posted
53 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

()>>

  • Haha 1
Posted
3 hours 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

Shocked Brahmi GIF - Shocked Brahmi Brahmanandam - Discover & Share GIFs

 

JOIN :

Use Joins to Combine Columns

 

UNON:

 

Use a union to combine rows

I know joke ga cheppuntaru but really lol 

Posted

గల్లి తిట్ల కాడి నుంచి మెదలు పెడితే

3ష చిత్రాల సంకలనం,

సినిమాలు,

రాజకూయాలు ,

కుల, మత,

ఇల్లు క్రయ విక్రయాలు,

ఊద్యోగాలు,

శ్రుంగారం ,

JAVA, SQL and .net ల సాంకేతిక మద్దతు (tech support),

ఇలా చెప్పుకుంటుూ పోతే కాదేది అనర్హం మన AFDB కి .

ఈ సందర్బంగా మన AFDB బ్రహ్మ ల కి దన్యవాదాలు.

 

 

Posted
9 minutes ago, KondapalliRaj said:

గల్లి తిట్ల కాడి నుంచి మెదలు పెడితే

3ష చిత్రాల సంకలనం,

సినిమాలు,

రాజకూయాలు ,

కుల, మత,

ఇల్లు క్రయ విక్రయాలు,

ఊద్యోగాలు,

శ్రుంగారం ,

JAVA, SQL and .net ల సాంకేతిక మద్దతు (tech support),

ఇలా చెప్పుకుంటుూ పోతే కాదేది అనర్హం మన AFDB కి .

ఈ సందర్బంగా మన AFDB బ్రహ్మ ల కి దన్యవాదాలు.

 

 

JoyfulImmaculateBrahmancow-small.gif

  • Upvote 1
Posted
10 minutes ago, KondapalliRaj said:

గల్లి తిట్ల కాడి నుంచి మెదలు పెడితే

3ష చిత్రాల సంకలనం,

సినిమాలు,

రాజకూయాలు ,

కుల, మత,

ఇల్లు క్రయ విక్రయాలు,

ఊద్యోగాలు,

శ్రుంగారం ,

JAVA, SQL and .net ల సాంకేతిక మద్దతు (tech support),

ఇలా చెప్పుకుంటుూ పోతే కాదేది అనర్హం మన AFDB కి .

ఈ సందర్బంగా మన AFDB బ్రహ్మ ల కి దన్యవాదాలు.

 

 

058a6bc0a611905d9a263e282e02c3fb_w200.we

  • 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...