Netezza SQL Interview Questions and Explanation

  • Post author:
  • Post last modified:January 9, 2019
  • Post category:General
  • Reading time:4 mins read

Below are some of best Netezza SQL interview questions that you may face:

How do you improve performance of SQL queries?

There are various options that you can use to improve the performance of Netezza queries.

Read below post for all SQL optimization options.

Steps to Optimize SQL Query Performance – Best Practices

How to calculate the Cumulative Sum in Netezza?

You can make use of the Netezza analytical functions to calculate the cumulative sum or running sum.

Read: Netezza Cumulative Sum, Average and Example

How do you Identify and Remove Duplicate Records in Netezza Table?

Netezza does not have primary or unique key constraints. You can insert the duplicate records in the Netezza table. There are no constraints to ensure uniqueness or primary key, but if you have a table and have loaded data twice, then you can de-duplicate in several ways.

Read: Identify and Remove Netezza Duplicate Records in Table

How do you update Netezza table records by joining other tables?

Netezza does supports the update Netezza tables records by joining other tables.

Read: Netezza Update Join Syntax – Update using other Table

How do you convert rows to column and vice versa in Netezza SQL?

Netezza does not have any pivot functions to converts rows to column. Read my other post on Netezza Pivot Rows to Column With Example

How do can you build the Google like search engine on top of Netezza? Give me Back-end SQL query that you use?

You can search the entire Netezza database for particular value. Read my other post on this topic Search for String Pattern in Netezza Database: Google Like Search

How do you count the character occurrence in the string using Netezza SQL?

The requirement here is to count the character occurrence in the string or value. For example, Let us assume we have “This is to verify the count of character in string” string or column value. Now, you have to write the query to count number of “t” in the string.

Below is the Netezza SQL query that you can use:

select length(translate(‘This is to verify the count of character in string’,’abcdefghijklmnopqrsuvwxyzABCDEFGHIJKLMNOPQRSUVWXYZ’,”))

Explain me how Netezza updates records in the table?

Netezza update record operation is costlier. IBM Netezza does not perform updates, but rather does deletes the records and inserts updated values. Read my other post on the How Netezza Update Records in Tables?

How do you Count Records from all Tables in Database?

There are couple of options available. One is to build the SQL query with UNION ALL operation and other one is to use nz_db_tables_rowcount script. Read post Netezza Count Records from all Tables in Database and Example

Netezza count specific character from string

If you ever get question to count number of character in the given string or provide top 10 names that have maximum number of ‘s’ in it, then you can do that by using translate and length functions in Netezza. Below is the query for your reference:

TRAINING.ADMIN(ADMIN)=> select length(translate(‘stockmarkets’,’abcdefghijklmnopqrtuvwxyzABCDEFGHIJKLMNOPQRTUVWXYZ’,”));

This Post Has One Comment

  1. Margaret

    Hello Vithal,

    Allow me to show my gratitude bloggers. You guys are like unicorns. Never seen but always spreading magic. Your content is yummy. So, satisfied.

    I need some help as to how I write some SQL logic if anyone can help me please.
    Database trigger is stored PL/SQL program unit associated with a specific database table. Usages are Audit data modifications, Log events transparently, enforce complex business rules Derive column values automatically, Implement complex security authorizations. Maintain replicate tables.
    I need to apply logic that tells me how much income I receive each month. Essentially taking my total contract Value (Variable: Contract_Val) and dividing that out against the volume of live accounts only during the current reporting month.
    Example: If I have a contract for £12,000 that was signed 01/01/2018, this would generate £1,000 per month until contract expires 01/01/2019.
    This is my current code that I will need to build on to apply this logic but im just not sure how. Any help will be greatly appreciated
    select
    JOB_NUMBER,
    contract type],
    contract_val,
    format (date_in, ‘dd-MMM-yyyy’) as Date_In,
    format (DATE_out, ‘dd-MMM-yyyy’) as Date_Out,
    case
    when contract type in (’01p’,’02nb’,’03R’,’04O’,’05C’,’06x’,’07p’,’08s’,’09PR’,’10ta’) then ‘Actual’ end as Contract_Type

    from summary
    left join f_summary
    on summary.job_number = f_summary.job_number

    where contract type in ((’01p’,’02nb’,’03R’,’04O’,’05C’,’06x’,’07p’,’08s’,’09PR’,’10ta’)

    Once again thanks for your tutorial.

    Grazie,
    Margaret

Comments are closed.