Skip to content

Trigger created with compilation errors

I wrote this trigger to discount the top client in the database by 10% when a new purchase is made: However when i execute this statement i receive this message: Can someone please tell me what I am doing wrong? Thanks, Alex. UPDATE – Errors: Solution: Answer I don’t have your tables to hand so I …

How to get the current effective date in Oracle?

I have a table like the following: TID TName EffectiveDate 1 A 2011-7-1 2 A 2011-8-1 3 A 2011-9-1 4 A 2011-10-1 5 B 2011-8-1 6 B 2011-9-1 7 B 2011-10-1 8 C 2011-9-1 If today is 2011-9-10, I wish the query result will be like this: TID TName EffectiveDate Status 1 A 2011-7-1 Invalid 2 A 2011-8-1 Invalid 3

SQL query to find distinct values in two tables?

I would like to find the distinct Code values and get a return like this: I can’t figure out how to write a SQL query that would return me the above results. Anyone have any experience with a query like this or similar? Answer In proper RDBMS: In MySQL… the UNION removes duplicates

left join returning more than expected

Using the following query table1 returns 16 rows and table2 returns 35 rows. I was expecting the above query to return 16 rows because of the left join, but it is returning 35 rows. right join also returns 35 rows Why is this happening and how do I get it to return 16 rows? Answer LEFT JOIN can return multipl…

How can I return pivot table output in MySQL?

If I have a MySQL table looking something like this: company_name action pagecount ——————————- Company A PRINT 3 Company A PRINT 2 Company A PRINT 3 Company B EMAIL Company B PRINT 2 Company B PRINT 2 Company B PRINT 1 Company A PRINT 3 Is it possibl…