Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7549237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:54:01+00:00 2026-05-30T09:54:01+00:00

Strugle with optimizing this subquery that count item: SELECT @crewid:=crewid AS `crewid`, COUNT(id) AS

  • 0

Strugle with optimizing this subquery that count item:

SELECT @crewid:=crewid AS `crewid`, COUNT(id) AS `number_documents`,
        (SELECT COUNT(id) FROM tblScan WHERE classification IS NOT NULL AND crewId = @crewid) AS `classified`,
        (SELECT COUNT(id) FROM tblScan WHERE classification IS NULL AND crewId = @crewid) AS `unclassified`,
        (SELECT CONCAT(name, ' ', surname) FROM tblcrew WHERE crewId = @crewid) AS `crewname`,
        (SELECT uploadeddate FROM tblScan WHERE crewid = @crewid ORDER BY uploadeddate DESC LIMIT 0,1) AS `uploadeddate`,
        (SELECT uploadedby FROM tblScan WHERE crewid = @crewid ORDER BY uploadedby DESC LIMIT 0,1) AS `uploadedby`,
        (SELECT updateddate FROM tblScan WHERE crewid = @crewid AND updateddate IS NOT NULL ORDER BY updateddate DESC LIMIT 0,1) AS `updateddate`,
        (SELECT updatedby FROM tblScan WHERE crewid = @crewid AND updatedby IS NOT NULL ORDER BY updatedby DESC LIMIT 0,1) AS `updatedby`
        FROM tblScan

Hope someone could help

Thanks,
Dels

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:54:02+00:00Added an answer on May 30, 2026 at 9:54 am
    SELECT 
       `tblScan`.`crewId` AS `crewid`
       COUNT(`tblScan`.`id`) AS `number_documents`,
       SUM(IF(`tblScan`.`classification` IS NOT NULL,1,0)) AS `classified`,
       SUM(IF(`tblScan`.`classification` IS NULL,1,0)) AS `unclassified`,
       CONCAT(`tblcrew`.`name`, ' ', `tblcrew`.`surname`) AS `crewname`,
       MAX(`tblScan`.`uploadeddate`) AS `uploadeddate`,
       MAX(`tblScan`.`uploadedby`) AS `uploadedby`,
       MAX(IFNULL(`tblScan`.`updateddate`,'0000-01-01')) AS `updateddate`,
       MAX(IFNULL(`tblScan`.`updatedby`,'0')) AS `updatedby`
    FROM tblScan
    INNER JOIN tblcrew ON `tblcrew`.`crewId`=`tblScan`.`crewId`
    GROUP BY `tblScan`.`crewId`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I strugle with this for second day... I have an NSArray of ints, wrapped
Hope that this helps a lot of people who struggle with installing OGRE on
I again need help by you, this time I struggle with covariance, contravariance, delegates
I struggle to write Makefiles and I'm building up some examples to learn from.
This is a continuation of the ongoing struggle to reduce my memory load mention
I'm a complete C# AND MVC noob, so this one's been a bitter struggle
I'm a Scala beginner and this piece of code makes me struggle. Is there
This has been an ongoing struggle for me for the last four days. I
It's very simple task, but I struggle for hours. I have parse xml from
I'm sure this has to do with scope, but I always seem to struggle

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.