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 8881965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:27:33+00:00 2026-06-14T20:27:33+00:00

I have this query: select MONTH(x.status_date) m , YEAR(x.status_date) y from [XREF_WET_MASTER] x join

  • 0

I have this query:

select MONTH(x.status_date) m
, YEAR(x.status_date) y
from [XREF_WET_MASTER] x
join F_ACCESSION_DAILY f
on x.accession_id=f.accession_id
pivot (count(*) for f.REQUISITION_TYPE in ([req1],[req2],[req3])
) as CountofThatTypeofReq

and i am getting this error:

Incorrect syntax near ‘*’.

on the count(*) line

here are the expected results:

+---+------+------+------+------+
| m |  y   | req1 | req2 | req3 |
+---+------+------+------+------+
| 1 | 2010 |   34 |    3 |    6 |
| 2 | 2010 |   56 |    6 |    0 |
| 3 | 2010 |    5 |   33 |    4 |
+---+------+------+------+------+

I would be most grateful for any guidance on this pivot!

  • 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-06-14T20:27:34+00:00Added an answer on June 14, 2026 at 8:27 pm

    Instead of count(*), you should be able to use something like the following:

    select *
    from
    (
      select MONTH(x.status_date) m
        , YEAR(x.status_date) y
        , f.REQUISITION_TYPE
        , f.accession_id
      from [XREF_WET_MASTER] x
      join F_ACCESSION_DAILY f
        on x.accession_id=f.accession_id
    ) src
    pivot 
    (
      count(REQUISITION_TYPE) 
      for REQUISITION_TYPE in ([req1],[req2],[req3])
    ) as CountofThatTypeofReq
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this simple query : SELECT YEAR(P.DateCreated) ,MONTH(P.DateCreated) ,COUNT(*) AS cnt FROM tbl1,
I have query like this : SELECT EXTRACT(MONTH FROM d.mydate) AS synmonth, SUM(apcp) AS
I have this MySQL query that makes use of MONTH() and YEAR() : SELECT
I have the following query: select count(L.ID) from LA inner join L on (LA.leadid
So far I have this query SELECT COUNT(f.code_id) as item_count, f.code_desc FROM foo f
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
i have this query: SELECT `completed`.`ID` AS `ID`,`completed`.`level` AS `level`,`completed`.`completed_in` AS `completed_in`, COUNT(1) AS
I have this query: SELECT * From checkfinale where AssociateID = 51 AND `CompletedDate`
I have this query: SELECT COUNT(*) AS invoice_count, IFNULL(SUM(qa_invoices.invoice_total), 0) AS invoice_total, IFNULL(SUM(qa_invoices.invoice_discount) ,0)
I'm using this sql query: select sysdate, sysdate - INTERVAL '6' month from dual;

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.