Skip to content

Tag: sql

SQL CASE with multiple join

I am trying to run a sql select code as below. I am trying to fetch the trans_date which will either be in asutrans or asuhistr. But the below code doesnt give me any value and nor does it fail. Do you think we can use CASE statement like that? If I run the codes separately, then it does give

how to add select statement in IN clause in pivot

iam using pivot table in SQL query.. i need to make some columns as rowss, but i need to use select statement in IN clause where we givt option like this normally we give option like but with select statement its giving me error?? what can be done. Answer use this i got answer from some of google posts

Use select inside ‘filename’ property of utl_file.fopen

I have a procedure that extracts data from a view and stores it on disc in CSV format. I’d like a name of the file to contain the most recent timestamp from table MY_TIMESTAMPS. For now it looks like this: The part with (select to_char(max(EVENT_TS)) from MY_TIMESTAMPS) throws an error. How can I set th…

Count the number of times word appears in a single column

I’m attempting to count the number of times apples and oranges appear in my fruit column. The table looks like this: Expected output: My code thus far. I’m not sure how to do it when both appear and how to add them to the totals. I’m sure there is an easier way that this. Cheers Answer If th…