开发者

How Do I display current date and time in Toad for Oracle?

开发者 https://www.devze.com 2023-02-25 15:32 出处:网络
I have a sql statement that counts the units(cable boxes) that were refurbished (had damaged parts replaced) and total units(cable boxes that just went through refurb and had nothing replaced) and it\

I have a sql statement that counts the units(cable boxes) that were refurbished (had damaged parts replaced) and total units(cable boxes that just went through refurb and had nothing replaced) and it's supposed to do this count regularly (every time a unit is processed the count). Can someone please help me? Thank you.

Justin

Heres my sql code so far:

SELECT COUNT(*) FROM cxadminn开发者_开发百科.repair_part

WHERE repair_type = 'REFURB' and created_date >?


SELECT COUNT(*) 
FROM cxadminn.repair_part
WHERE repair_type = 'REFURB' 
  and created_date > sysdate

To exclude the time that is part of any oracle DATE column, you would need to use this:

SELECT COUNT(*) 
FROM cxadminn.repair_part
WHERE repair_type = 'REFURB' 
  and trunc(created_date) > trunc(sysdate)


I think you want the current date and time when you run the query, which is not the same as created_date, right?

select COUNT(*), 
to_char(sysdate, 'Dy DD-Mon-YYYY HH24:MI:SS') as "Current Time"
FROM cxadminn.repair_part
WHERE repair_type = 'REFURB'

I removed the and created_date >? from the WHERE clause because it doesn't make sense to me, unless you can have items in your table whose created_date is in the future.


SELECT COUNT(*) FROM cxadminn.repair_part
WHERE repair_type = 'REFURB' and created_date > sysdate

or

created_date > to_date('01.01.11 01:01:01', 'dd.mm.yyyy hh:mi:ss')
0

精彩评论

暂无评论...
验证码 换一张
取 消