Skip to content
Advertisement

Tag: sql

Get Max from a joined table

I write this script in SQL server And I want get the food name with the Max of order count From this Joined Table . I can get Max value correct but when I add FoodName is select It give me an error. …

Convert day of week name to day of week number Vertica

With this way – SELECT TO_CHAR(NOW(), ‘DAY’); I can get a day of week name(E.G. MONDAY). With SELECT dayofweek(NOW()); I can get the number of the day of week. (E.G 1) QUESTION: How to convert day of week name to day of week number. (E.G MONDAY -> 1) SMTH like TO_NUMBER(‘MONDAY’, ‘DAY’); –> 1 (just for example, don’t working) Answer

Oracle decode equivalent function to Postgres

So, I’m in migrating database from oracle to Postgres, and this is my error: and here’s my code : do you have any clue? From what I’ve read, some say to replace the decode function with COALESCE, but I don’t have any idea how the syntax is. Answer You could use a standard case expression:

How to include OPENJSON in View?

My JSON object is stored in the table (single cell). Right now, I’m reading the cell and saving the value to @json NVARCHAR(MAX) , but that obviously doesn’t work in views. How can I do something like this? Answer You can use cross apply to apply openjson() to each and every row of your table:

Adding parameter to SQL query

I want to get some data from Excel table using SQL-query inside macros. My code is: If I try using sql = “SELECT * FROM [Page 1$] WHERE Job = 2”, I have no errors. How could I paste Value2 and Value1 values inside my SQL-query? Answer Try like this

Advertisement