Jump to content

Sql Query Help Please


Recommended Posts

Posted

Assume that table  DEPARTMENTS is using DEPARTMENT_ID as the

primary key. A sample of records in the table can be found as follows

 

 

 Department ID        Dept Name            ManagerID              location ID

 

10                                   Administration                200                                1700

20                                   Marketing                          201                                 1800

50                                   Shipping                             124                                 1500

60                                   IT                                           103                                 1400

 

80                                       Sales                                              149                                      2500

90                                        Executive                                    100                                     1700

110                                    Accounting                                  205                                       1700

190                                    Contracting                                                                               1700

 

 

Write a SQL statement to find IDs of department pair which are in different location with

known manager, and both department names end with “ing”.

 

Can any one help this with Solution

thanks

Posted

select  a.department_id

from  departments a

join departments c on a.department_id = c. department_id

where a. location_id  <> c.location_id and 

and a.manager_id is not null 

 and a. department name like '% ing'

Posted

select  a.department_id

from  departments a

join departments c on a.department_id = c. department_id

where a. location_id  <> c.location_id and 

and a.manager_id is not null 

 and a. department name like '% ing'

 

 

dept id primary key antunnadu... alantappudu oka dept multiple locations undadhu ga 

Posted

Assume that table  DEPARTMENTS is using DEPARTMENT_ID as the

primary key. A sample of records in the table can be found as follows

 

 

 Department ID        Dept Name            ManagerID              location ID

 

10                                   Administration                200                                1700

20                                   Marketing                          201                                 1800

50                                   Shipping                             124                                 1500

60                                   IT                                           103                                 1400

 

80                                       Sales                                              149                                      2500

90                                        Executive                                    100                                     1700

110                                    Accounting                                  205                                       1700

190                                    Contracting                                                                               1700

 

 

Write a SQL statement to find IDs of department pair which are in different location with

known manager, and both department names end with “ing”.

 

Can any one help this with Solution

thanks

select department_id from departments x join deparments y on x.locationid<>y.loctaionid where dept_name like '%ing' and managerid is not 'null';

Posted

dept id primary key antunnadu... alantappudu oka dept multiple locations undadhu ga 

kani same location lo different dept unnai.. the query needs depts in different location

Posted

dept id primary key antunnadu... alantappudu oka dept multiple locations undadhu ga 

artham kale mama ...let me read again ... i might be wrong 

Posted

kani same location lo different dept unnai.. the query needs depts in different location

 

 

correcte... kani data choodu... e dept multiple locations lo ledu... paiga dept PK

 

 

oka locn lo multiple dept undochu kani vise versa kudaradu... unless Dept+Locn PK aithe

Posted

select department_id from departments x join deparments y on x.locationid<>y.loctaionid where dept_name like '%ing' and managerid is not 'null';

nasty unkul ... ila un indexed fields meeda join cheyaku ...pedda tables aithe biscuit padtadi 

Posted

nasty unkul ... ila un indexed fields meeda join cheyaku ...pedda tables aithe biscuit padtadi 

req ade ga...kani nuvvu dept id meeda ela sesav man? pedda tappu nee query..asalu adigine list of dept ids nuvvemo dept ids meda join rasesav asalu em job sestunnav nee silver lo naa gold

Posted

correcte... kani data choodu... e dept multiple locations lo ledu... paiga dept PK

 

 

oka locn lo multiple dept undochu kani vise versa kudaradu... unless Dept+Locn PK aithe

naa query ite correct kada mayya inka ee req ki alane rayali 

Posted

req ade ga...kani nuvvu dept id meeda ela sesav man? pedda tappu nee query..asalu adigine list of dept ids nuvvemo dept ids meda join rasesav asalu em job sestunnav nee silver lo naa gold

nee banda bada self join ....they will match ... you will get the results naa 

Posted

nee banda bada self join ....they will match ... you will get the results naa 

req lo same depts ani evadu adigaadu nee bonda nee tadullage unnai nee querys #silverism @3$%

 

req sarriga saduvu different location, known manager , and dept names ending with 'ing' why the frock did you join for same dept ids?

Posted

req lo same depts ani evadu adigaadu nee bonda nee tadullage unnai nee querys #silverism @3$%

 

req sarriga saduvu different location, known manager , and dept names ending with 'ing' why the frock did you join for same dept ids?

husshhhhhhhh  ...ade ga cheptunna unkul ...  self join  chesappudu primary key meeda join chesko eppudaina ..... mostly they will be indexed 

Posted

husshhhhhhhh  ...ade ga cheptunna unkul ...  self join  chesappudu primary key meeda join chesko eppudaina ..... mostly they will be indexed 

naku nerpistunnava sql edisinatte undi nee sql   #selfjoinsilver  @3$%

×
×
  • Create New...