0

I have a query that I am trying to combine but with different columns. The specifics of this are:

  • Same table
  • Different Where clause
  • Oracle DB
  • Ran in DBVisualizer

This is what I was trying to do: it runs but it does not join the two columns. they are being outputted into separate Result tabs in DBVisualizer

    Select count (distinct CODE)   AS Comp_PCT
    from cons.GM
    Where POLICY='NR'
    And PCT is null

    UNION

    Select count (distinct CODE) AS Comp_DTY
    from cons.GM  
    Where POLICY='NR'
    And DTY is null
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
JJCADIZ
  • 143
  • 2
  • 14
  • I don't know DBVisualizer, but - try to remove empty lines around UNION. – Littlefoot Jan 19 '18 at 10:07
  • Why do you think a `UNION` would "join" the columns? Please **[EDIT]** your question and add some [sample data](http://plaintexttools.github.io/plain-text-table/) and the expected output based on that data. [**Formatted text**](http://stackoverflow.com/help/formatting) please, [**no screen shots**](http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking-a-question/285557#285557). **[edit]** your question - do **not** post code or additional information in comments. –  Jan 19 '18 at 14:32

1 Answers1

0

I don't know that this answer is a correct form:

SELECT
  (Select count (distinct CODE)
    from cons.GM
    Where POLICY='NR'
    And PCT is null) AS Comp_PCT,
  (Select count (distinct CODE)
    from cons.GM  
    Where POLICY='NR'
    And DTY is null)  AS Comp_DTY
sk11z00
  • 124
  • 1
  • 6