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

  • Home
  • SEARCH
  • 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 6666009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:47:00+00:00 2026-05-26T02:47:00+00:00

Sample data: Data table1: prodid type location(there are more columns, just ignoring them for

  • 0

Sample data:

Data table1:
prodid  type location(there are more columns, just ignoring them for this example)
p001        t1      l1
p002        t1      l2
p003        t3      l1
p004        t2      
p005        t1      l1

Need a summary like
type    Blank [l1]  [l2]
t1      0           2           1
t2      1           0           0
t3      0           1           0

The problem am facing is with the blank values in the location field. I donno how to represent the blank location values in the pivot query.

Pivot query:
1: select type, [] as Blank, [l1], [l2], Blank + [l1] + [l2] as Total from
2: (select type, location from table1)
3: pivot 
4: (count(location) for location in ([],[l1],[l2]) t2

Error on line 1 & 4
An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name. 
  • 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-26T02:47:01+00:00Added an answer on May 26, 2026 at 2:47 am

    How about just swapping out the null/blank locations for a dummy value. So change

    select type, location from table1
    

    to

    select type, CASE WHEN location is null THEN 'ZZ' ELSE location END as location from table1
    

    Then the column will be zz or whatever dummy value you choose

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following is the sample data. I need to make 3 copies of this data
I have data in my database that looks like this: Date (DateTime) Type (varchar)
Sample data in the table with 4 columns : 1st row A1 B1 C1
For my question lets consider the following sample table data: ProductID    ProductName    Price   Category 1                Apple                 5.00       Fruits
Sample data: !!Part|123456,ABCDEF,ABC132!! The comma delimited list can be any number of any combination
Sample Data: 603 Some garbage data not related to me, 55, 113 -> 1-ENST0000
I got some sample data in a Table Testing which consists of two fields:
I am learning cakePHP 1.26. I got some sample data in a Table Testing
I have data in a table that looks like the following sample data: varchar(20)
Some sample data: DECLARE @TARGET TABLE ( ID INT, value INT ) ; DECLARE

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.