Troubles with Oracle SQL query Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceHow can I prevent SQL injection in PHP?Add a column with a default value to an existing table in SQL ServerGet list of all tables in Oracle?Inserting multiple rows in a single SQL query?SQL Server: How to Join to first rowHow do I UPDATE from a SELECT in SQL Server?Finding duplicate values in a SQL tableHow to query MongoDB with “like”?Reference - What does this error mean in PHP?How to import an SQL file using the command line in MySQL?

I'm having difficulty getting my players to do stuff in a sandbox campaign

How do I keep my slimes from escaping their pens?

If A makes B more likely then B makes A more likely"

What would be Julian Assange's expected punishment, on the current English criminal law?

What do you call a plan that's an alternative plan in case your initial plan fails?

Stop battery usage [Ubuntu 18]

How is simplicity better than precision and clarity in prose?

How does modal jazz use chord progressions?

Need a suitable toxic chemical for a murder plot in my novel

Is above average number of years spent on PhD considered a red flag in future academia or industry positions?

Notation for two qubit composite product state

Geometric mean and geometric standard deviation

Why use gamma over alpha radiation?

Simulating Exploding Dice

Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?

Windows 10: How to Lock (not sleep) laptop on lid close?

Blender game recording at the wrong time

How should I respond to a player wanting to catch a sword between their hands?

3 doors, three guards, one stone

What did Darwin mean by 'squib' here?

Problem when applying foreach loop

Strange behaviour of Check

Stars Make Stars

Can smartphones with the same camera sensor have different image quality?



Troubles with Oracle SQL query



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceHow can I prevent SQL injection in PHP?Add a column with a default value to an existing table in SQL ServerGet list of all tables in Oracle?Inserting multiple rows in a single SQL query?SQL Server: How to Join to first rowHow do I UPDATE from a SELECT in SQL Server?Finding duplicate values in a SQL tableHow to query MongoDB with “like”?Reference - What does this error mean in PHP?How to import an SQL file using the command line in MySQL?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-2















I have two tables and I want to extract the following requirements :



  • Job Title.

  • Number of Users.

Tables and sample data:



 **Job_Applied** **Jobs_posted**

Job_id Empl_id User_id | Job_id Empl_id Job_Title
------------------------ --------------------------
1 2 3 | 1 2 Android
1 2 4 | 2 2 Web
1 2 5 | 3 4 Java
2 2 3 |
2 2 3 |
2 2 7 |
3 2 5 |


I have tried:



 Select count(User_id) as Users , Job_Title 
from Jobs_posted
inner join Jobs_Applied on Jobs_posted.job_id = Jobs_Applied.job_id.


I get number of users that applied on job. How can I get job_title with zero number of users. I have also tried left join. Kindly help.










share|improve this question



















  • 1





    You title has Oracle SQL and you tagged mysql. So, which of the two DBMS are you using, Oracle or MySQL?

    – Thorsten Kettner
    Mar 22 at 7:47











  • What are the tables's primary keys? What role does empl_id play? Is this column important for the query or can we safely ignore it?

    – Thorsten Kettner
    Mar 22 at 7:49











  • The combination (Job_id, Empl_id, User_id) = (2, 2, 3) occurs twice in Job_Applied. Do you want this user count twice for the job accordingly or just once?

    – Thorsten Kettner
    Mar 22 at 7:52











  • I am downvoting the request. As my questions above show, it is incomplete, and the OP hasn't answered any of the questions. This makes the request rather worthless for any other reader than the OP himself.

    – Thorsten Kettner
    Mar 22 at 9:01

















-2















I have two tables and I want to extract the following requirements :



  • Job Title.

  • Number of Users.

Tables and sample data:



 **Job_Applied** **Jobs_posted**

Job_id Empl_id User_id | Job_id Empl_id Job_Title
------------------------ --------------------------
1 2 3 | 1 2 Android
1 2 4 | 2 2 Web
1 2 5 | 3 4 Java
2 2 3 |
2 2 3 |
2 2 7 |
3 2 5 |


I have tried:



 Select count(User_id) as Users , Job_Title 
from Jobs_posted
inner join Jobs_Applied on Jobs_posted.job_id = Jobs_Applied.job_id.


I get number of users that applied on job. How can I get job_title with zero number of users. I have also tried left join. Kindly help.










share|improve this question



















  • 1





    You title has Oracle SQL and you tagged mysql. So, which of the two DBMS are you using, Oracle or MySQL?

    – Thorsten Kettner
    Mar 22 at 7:47











  • What are the tables's primary keys? What role does empl_id play? Is this column important for the query or can we safely ignore it?

    – Thorsten Kettner
    Mar 22 at 7:49











  • The combination (Job_id, Empl_id, User_id) = (2, 2, 3) occurs twice in Job_Applied. Do you want this user count twice for the job accordingly or just once?

    – Thorsten Kettner
    Mar 22 at 7:52











  • I am downvoting the request. As my questions above show, it is incomplete, and the OP hasn't answered any of the questions. This makes the request rather worthless for any other reader than the OP himself.

    – Thorsten Kettner
    Mar 22 at 9:01













-2












-2








-2








I have two tables and I want to extract the following requirements :



  • Job Title.

  • Number of Users.

Tables and sample data:



 **Job_Applied** **Jobs_posted**

Job_id Empl_id User_id | Job_id Empl_id Job_Title
------------------------ --------------------------
1 2 3 | 1 2 Android
1 2 4 | 2 2 Web
1 2 5 | 3 4 Java
2 2 3 |
2 2 3 |
2 2 7 |
3 2 5 |


I have tried:



 Select count(User_id) as Users , Job_Title 
from Jobs_posted
inner join Jobs_Applied on Jobs_posted.job_id = Jobs_Applied.job_id.


I get number of users that applied on job. How can I get job_title with zero number of users. I have also tried left join. Kindly help.










share|improve this question
















I have two tables and I want to extract the following requirements :



  • Job Title.

  • Number of Users.

Tables and sample data:



 **Job_Applied** **Jobs_posted**

Job_id Empl_id User_id | Job_id Empl_id Job_Title
------------------------ --------------------------
1 2 3 | 1 2 Android
1 2 4 | 2 2 Web
1 2 5 | 3 4 Java
2 2 3 |
2 2 3 |
2 2 7 |
3 2 5 |


I have tried:



 Select count(User_id) as Users , Job_Title 
from Jobs_posted
inner join Jobs_Applied on Jobs_posted.job_id = Jobs_Applied.job_id.


I get number of users that applied on job. How can I get job_title with zero number of users. I have also tried left join. Kindly help.







mysql sql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 9:46









marc_s

585k13011261272




585k13011261272










asked Mar 22 at 7:40









Jahanzeb AwanJahanzeb Awan

45




45







  • 1





    You title has Oracle SQL and you tagged mysql. So, which of the two DBMS are you using, Oracle or MySQL?

    – Thorsten Kettner
    Mar 22 at 7:47











  • What are the tables's primary keys? What role does empl_id play? Is this column important for the query or can we safely ignore it?

    – Thorsten Kettner
    Mar 22 at 7:49











  • The combination (Job_id, Empl_id, User_id) = (2, 2, 3) occurs twice in Job_Applied. Do you want this user count twice for the job accordingly or just once?

    – Thorsten Kettner
    Mar 22 at 7:52











  • I am downvoting the request. As my questions above show, it is incomplete, and the OP hasn't answered any of the questions. This makes the request rather worthless for any other reader than the OP himself.

    – Thorsten Kettner
    Mar 22 at 9:01












  • 1





    You title has Oracle SQL and you tagged mysql. So, which of the two DBMS are you using, Oracle or MySQL?

    – Thorsten Kettner
    Mar 22 at 7:47











  • What are the tables's primary keys? What role does empl_id play? Is this column important for the query or can we safely ignore it?

    – Thorsten Kettner
    Mar 22 at 7:49











  • The combination (Job_id, Empl_id, User_id) = (2, 2, 3) occurs twice in Job_Applied. Do you want this user count twice for the job accordingly or just once?

    – Thorsten Kettner
    Mar 22 at 7:52











  • I am downvoting the request. As my questions above show, it is incomplete, and the OP hasn't answered any of the questions. This makes the request rather worthless for any other reader than the OP himself.

    – Thorsten Kettner
    Mar 22 at 9:01







1




1





You title has Oracle SQL and you tagged mysql. So, which of the two DBMS are you using, Oracle or MySQL?

– Thorsten Kettner
Mar 22 at 7:47





You title has Oracle SQL and you tagged mysql. So, which of the two DBMS are you using, Oracle or MySQL?

– Thorsten Kettner
Mar 22 at 7:47













What are the tables's primary keys? What role does empl_id play? Is this column important for the query or can we safely ignore it?

– Thorsten Kettner
Mar 22 at 7:49





What are the tables's primary keys? What role does empl_id play? Is this column important for the query or can we safely ignore it?

– Thorsten Kettner
Mar 22 at 7:49













The combination (Job_id, Empl_id, User_id) = (2, 2, 3) occurs twice in Job_Applied. Do you want this user count twice for the job accordingly or just once?

– Thorsten Kettner
Mar 22 at 7:52





The combination (Job_id, Empl_id, User_id) = (2, 2, 3) occurs twice in Job_Applied. Do you want this user count twice for the job accordingly or just once?

– Thorsten Kettner
Mar 22 at 7:52













I am downvoting the request. As my questions above show, it is incomplete, and the OP hasn't answered any of the questions. This makes the request rather worthless for any other reader than the OP himself.

– Thorsten Kettner
Mar 22 at 9:01





I am downvoting the request. As my questions above show, it is incomplete, and the OP hasn't answered any of the questions. This makes the request rather worthless for any other reader than the OP himself.

– Thorsten Kettner
Mar 22 at 9:01












2 Answers
2






active

oldest

votes


















0














You just need to group by Job_Title



Select count(distinct User_id) as Users , p.Job_Title 
from Jobs_posted p
left join Jobs_Applied a
on p.job_id = a.job_id and p.Empl_id = a.Empl_id
group by p.Job_Title





share|improve this answer

























  • Thank you. But if jobs_applied table is empty I want to show job_title with number of user = 0.

    – Jahanzeb Awan
    Mar 22 at 7:50











  • @JahanzebAwan you're welcome, you need to use left join then. Because jobs_applied is on the right side. If it was on the left side you would need to use a right join.

    – Barbaros Özhan
    Mar 22 at 7:52



















0














use left join



 Select count(a.User_id) as Users , p.Job_Title 
from Jobs_posted p
left join Jobs_Applied a
on p.job_id = a.job_id and p.Empl_id=a.Empl_id
group by p.Job_Title





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55294925%2ftroubles-with-oracle-sql-query%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You just need to group by Job_Title



    Select count(distinct User_id) as Users , p.Job_Title 
    from Jobs_posted p
    left join Jobs_Applied a
    on p.job_id = a.job_id and p.Empl_id = a.Empl_id
    group by p.Job_Title





    share|improve this answer

























    • Thank you. But if jobs_applied table is empty I want to show job_title with number of user = 0.

      – Jahanzeb Awan
      Mar 22 at 7:50











    • @JahanzebAwan you're welcome, you need to use left join then. Because jobs_applied is on the right side. If it was on the left side you would need to use a right join.

      – Barbaros Özhan
      Mar 22 at 7:52
















    0














    You just need to group by Job_Title



    Select count(distinct User_id) as Users , p.Job_Title 
    from Jobs_posted p
    left join Jobs_Applied a
    on p.job_id = a.job_id and p.Empl_id = a.Empl_id
    group by p.Job_Title





    share|improve this answer

























    • Thank you. But if jobs_applied table is empty I want to show job_title with number of user = 0.

      – Jahanzeb Awan
      Mar 22 at 7:50











    • @JahanzebAwan you're welcome, you need to use left join then. Because jobs_applied is on the right side. If it was on the left side you would need to use a right join.

      – Barbaros Özhan
      Mar 22 at 7:52














    0












    0








    0







    You just need to group by Job_Title



    Select count(distinct User_id) as Users , p.Job_Title 
    from Jobs_posted p
    left join Jobs_Applied a
    on p.job_id = a.job_id and p.Empl_id = a.Empl_id
    group by p.Job_Title





    share|improve this answer















    You just need to group by Job_Title



    Select count(distinct User_id) as Users , p.Job_Title 
    from Jobs_posted p
    left join Jobs_Applied a
    on p.job_id = a.job_id and p.Empl_id = a.Empl_id
    group by p.Job_Title






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 22 at 7:51

























    answered Mar 22 at 7:42









    Barbaros ÖzhanBarbaros Özhan

    15.1k71634




    15.1k71634












    • Thank you. But if jobs_applied table is empty I want to show job_title with number of user = 0.

      – Jahanzeb Awan
      Mar 22 at 7:50











    • @JahanzebAwan you're welcome, you need to use left join then. Because jobs_applied is on the right side. If it was on the left side you would need to use a right join.

      – Barbaros Özhan
      Mar 22 at 7:52


















    • Thank you. But if jobs_applied table is empty I want to show job_title with number of user = 0.

      – Jahanzeb Awan
      Mar 22 at 7:50











    • @JahanzebAwan you're welcome, you need to use left join then. Because jobs_applied is on the right side. If it was on the left side you would need to use a right join.

      – Barbaros Özhan
      Mar 22 at 7:52

















    Thank you. But if jobs_applied table is empty I want to show job_title with number of user = 0.

    – Jahanzeb Awan
    Mar 22 at 7:50





    Thank you. But if jobs_applied table is empty I want to show job_title with number of user = 0.

    – Jahanzeb Awan
    Mar 22 at 7:50













    @JahanzebAwan you're welcome, you need to use left join then. Because jobs_applied is on the right side. If it was on the left side you would need to use a right join.

    – Barbaros Özhan
    Mar 22 at 7:52






    @JahanzebAwan you're welcome, you need to use left join then. Because jobs_applied is on the right side. If it was on the left side you would need to use a right join.

    – Barbaros Özhan
    Mar 22 at 7:52














    0














    use left join



     Select count(a.User_id) as Users , p.Job_Title 
    from Jobs_posted p
    left join Jobs_Applied a
    on p.job_id = a.job_id and p.Empl_id=a.Empl_id
    group by p.Job_Title





    share|improve this answer



























      0














      use left join



       Select count(a.User_id) as Users , p.Job_Title 
      from Jobs_posted p
      left join Jobs_Applied a
      on p.job_id = a.job_id and p.Empl_id=a.Empl_id
      group by p.Job_Title





      share|improve this answer

























        0












        0








        0







        use left join



         Select count(a.User_id) as Users , p.Job_Title 
        from Jobs_posted p
        left join Jobs_Applied a
        on p.job_id = a.job_id and p.Empl_id=a.Empl_id
        group by p.Job_Title





        share|improve this answer













        use left join



         Select count(a.User_id) as Users , p.Job_Title 
        from Jobs_posted p
        left join Jobs_Applied a
        on p.job_id = a.job_id and p.Empl_id=a.Empl_id
        group by p.Job_Title






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 22 at 7:46









        Zaynul Abadin TuhinZaynul Abadin Tuhin

        19.2k31135




        19.2k31135



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55294925%2ftroubles-with-oracle-sql-query%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript