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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:37:00+00:00 2026-05-30T12:37:00+00:00

I have a look up table, basically with credit card types ID | CCType

  • 0

I have a look up table, basically with credit card types

ID |  CCType         |
-----------------------
1  | AMEX            |
2  | VISA            |
3  | MASTER CARD     |
4  | OTHER           |

Then I have another table with transactions where CCTypeID is the ID in the look up table

TransID   |  CCTypeID   | TransactionName | OrderID |
-----------------------------------------------------
1         | 2           | BILLPAY         |10
2         | 4           | SECUREPAYMENT   |13
3         | 1           | BILLPAY         |15

Then finally I have another table with the orders

    OrderId | OrderDate   | Product   |   TransID  |
    ------------------------------------------------
    10      |  2012-02-27 |Grapes     | 1
    13      |  2012-02-26 |Wine       | 2
    14      |  2012-01-26 |Pepper     | 6
    15      |  2012-01-26 |Apple      | 1

I want to create a view that looks like this

OrderDate  | CCType      |  Processed
----------- ---------------------------
2012-02-27 | AMEX        |   0
2012-02-27 | VISA        |   1
2012-02-27 | MASTER CARD |   0
2012-02-27 | OTHER       |   0
2012-02-26 | AMEX        |   0
2012-02-26 | VISA        |   0
2012-02-26 | MASTER CARD |   0
2012-02-26 | OTHER       |   1

I have tried to RIGHT OUTER JOIN the credit card types with the transactions on the CCTypeID and ID respectively, then a INNER JOIN with orders on ORDERID, grouped by ORDER.DATE and CardType but it only shows whereever there are values, is there a way to make it so that it still lists the credit card types no matter if there are transactions or orders for the date? just show zero for that card type?.

Will truly appreciate the help.

  • 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-30T12:37:02+00:00Added an answer on May 30, 2026 at 12:37 pm

    Your basic query should be something like this…

    SELECT
      Orders.OrderDate,
      CardType.CCType,
      COUNT(*)
    FROM
      Orders
    LEFT JOIN
      Transactions
        ON  Transactions.TransID = Orders.TransID
        AND Transactions.OrderID = Orders.OrderID
    LEFT JOIN
      CardType
        ON CardType.ID = Transaction.CCTypeID
    GROUP BY
      Orders.OrderDate,
      CardType.CCType
    

    If you need “All Dates” to have values, then you need an extra table to join on. For example, make a table called calendar and pre-populate it with all the dates you’ll ever need, then create an index on the date field. Then you can re-order your query to force every combination that you want a record for…

    SELECT
      Calendar.Date,
      CardType.CCType,
      COUNT(Transaction.CCTypeID)
    FROM
      Calendar
    CROSS JOIN
      CardType
    LEFT JOIN
      (
        Transactions
      INNER JOIN
        Orders
          ON  Transactions.TransID = Orders.TransID
          AND Transactions.OrderID = Orders.OrderID
      )
        ON  CardType.ID   = Transactions.CCTypeID
        AND Calendar.Date = Orders.OrderDate
    WHERE
      Calendar.Date BETWEEN ??? AND ???
    GROUP BY
      Calendar.Date,
      CardType.CCType
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of tables which look like this Table 1 user_id |
I have to create one table using XSLT and CSS. The table should look
I have a table with contents that look similar to this: id | title
I have a table posts that could look like this: id | title |
i have a table (tbl_world) which look like this id | first_name | last_name
On my pages I have a table with rows that typically look like this:
I have a table with rowID, longitude, latitude, businessName, url, caption. This might look
I have created a table in postgreSQL. I want to look at the SQL
i have a table called propAmenities which holds two column amenity_id and property_id basically
I have a http server setup which basically needs to look up stuff in

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.