Toad World® Forums

Specific Dates - No Result


#1

Good Day,

My queries below is giving me no result. Is there a way to get the data for 2 specific dates? Also, I have tried getting the dates only and it is giving me no result either.

I have highlighted per color the script that I need to be link or get data from.

Thank you!!!

BR/// Anthony Arada

Query 1: Data from specific dates

SELECT DC_E_ERBS_EUTRANCELLFDD_RAW.ERBS
,DC_E_ERBS_EUTRANCELLFDD_RAW.EUtranCellFDD
,SUM( DC_E_ERBS_EUTRANCELLFDD_RAW.pmRrcConnEstabAtt ) AS ATTEMPTS_CURRENT
,SUM( DC_E_ERBS_EUTRANCELLFDD_RAW.pmRrcConnEstabAtt ) AS ATTEMPTS_PREVIOUS
FROM dc.DC_E_ERBS_EUTRANCELLFDD_RAW DC_E_ERBS_EUTRANCELLFDD_RAW
WHERE ( “DC_E_ERBS_EUTRANCELLFDD_RAW”.“ERBS” = ‘GNL03402’)
AND ( DC_E_ERBS_EUTRANCELLFDD_RAW.DATE_ID = ‘2017-1-19’)
AND ( DC_E_ERBS_EUTRANCELLFDD_RAW.DATE_ID = ‘2017-1-12’)
GROUP BY DC_E_ERBS_EUTRANCELLFDD_RAW.ERBS
,DC_E_ERBS_EUTRANCELLFDD_RAW.EUtranCellFDD

Query 2: Date only

SELECT DC_E_ERBS_EUTRANCELLFDD_RAW.DATE_ID AS DATE_CURRENT
,DC_E_ERBS_EUTRANCELLFDD_RAW.DATE_ID AS DATE_PREVIOUS
FROM dc.DC_E_ERBS_EUTRANCELLFDD_RAW DC_E_ERBS_EUTRANCELLFDD_RAW
WHERE ( DC_E_ERBS_EUTRANCELLFDD_RAW.DATE_ID = ‘2017-1-19’)
AND ( DC_E_ERBS_EUTRANCELLFDD_RAW.DATE_ID = ‘2017-1-12’)
GROUP BY DC_E_ERBS_EUTRANCELLFDD_RAW.DATE_ID
,DC_E_ERBS_EUTRANCELLFDD_RAW.DATE_ID


#2

Hi Anthony,

for me it looks like, you have wrong logic in WHERE statement.

If you need to have two results of dates, you have to use ‘OR’. No row of some column can exist in two states in same time.

I hope it will help you.

J.


#3

Thank you for the information but what I am trying to do in the diagram builder is attached below.

I need to subtract or get the delta for those attempts.

Is this even possible?


#4

In the WHERE, change AND to OR.

If that still does not work, it could be the formatting of the date value. This can change depending upon the type of database being used.

I connect to an Oracle database, my dates have to be formatted like this:

DC_E_ERBS_EUTRANCELLFDD_RAW.DATE_ID = TO_DATE (‘2017-01-19 00:00:00’, ‘yyyy/mm/dd hh24:mi:ss’)

Sometimes it wants it this way… DC_E_ERBS_EUTRANCELLFDD_RAW.DATE_ID BETWEEN (‘2017-01-12 00:00:00’ AND ‘2017-01-19 00:00:00’)


#5

Hi,

I have tried a different query. I got the results that I needed but it is giving me additional data (NULL).

Is there any way that I do not see the null values? How about the values (64,476 and 55,333) in the same row?

Thank you!!!

Here is my query:

SELECT DISTINCT DC_E_ERBS_EUTRANCELLFDD_RAW.ERBS

, DC_E_ERBS_EUTRANCELLFDD_RAW.EUtranCellFDD

, CASE WHEN DC_E_ERBS_EUTRANCELLFDD_RAW.DATE_ID = ‘2017-1-30’ THEN SUM(DC_E_ERBS_EUTRANCELLFDD_RAW.pmRrcConnEstabAtt)

END AS ATTEMPTS_CURRENT

, CASE WHEN DC_E_ERBS_EUTRANCELLFDD_RAW.DATE_ID = ‘2017-1-23’ THEN SUM(DC_E_ERBS_EUTRANCELLFDD_RAW.pmRrcConnEstabAtt)

END AS ATTEMPTS_PREVIOUS

FROM dc.DC_E_ERBS_EUTRANCELLFDD_RAW DC_E_ERBS_EUTRANCELLFDD_RAW

WHERE DC_E_ERBS_EUTRANCELLFDD_RAW.ERBS = ‘GNL03402’

GROUP BY DC_E_ERBS_EUTRANCELLFDD_RAW.ERBS

, DC_E_ERBS_EUTRANCELLFDD_RAW.EUtranCellFDD

, DC_E_ERBS_EUTRANCELLFDD_RAW.DATE_ID


#7

Add to your filter for the desired column to not be null. The exact syntax depends on the type of database being used. For Oracle it would be "AND

.<column_name> IS NOT NULL"