So there’s a Customer and a Seller and they’re both User. The only difference between them is that seller has a NameOfBusiness and customer does not. In the DAL I have this code: Is there a way to overload the query OR change the query so that you can fill in a NULL for NameOfBusiness? Answer Opti…
Tag: sql
Select a specific time in DB2 from the currenttime
I am trying to do a select and set the time to 10AM in DB2. Ive tried however this sets the time to 0:00:00, im trying to get it set to 10AM, is there a way to do this in DB2? Answer Please can you try this: Here is the DEMO Also, in your question example you have one open
How to merge rows into one row with separator
I need merge rows into one row for summary of calculation (SQL Server 2014). My SQL query is: Result of this query is: I would like to have this result: When add new currency (x), the result of new currency must be appended: Can somebody please help me with this topic? Many thanks Answer Something like this s…
CASE expression in WHERE clause for diferent and
Can I use case expression to build where like this? I need change where clause depending on the value of x variable. Answer An alternative to using OR is to use nested CASE statements: or you could simplify it to: However, you should check whether Oracle can use column indexes or if a separate function-based …
Transform table to smoothen records in one column
the situation (a real life situation) is: I have a table with “log” records, for simplicity let’s assume there are only columns NAME, TIME, STATE (in reality there are few more). There are cca 1 Milion rows in which there are 100 Names (computers) and cca 10 states (productive, idle, automat…
How to create all possible combinations with splitted items in SQL?
I have data as in below delimited format expected output – is the combination with each element and the element itself I am trying by splitting the data into different items as below any idea how we can create combination with splitted items? Thanks! Answer You have a couple of mistakes in your SQL. @da…
Will remove MySQL logs file impact the performance of the database?
One of our users is using Cloud SQL(MySQL). They turn on general logs flag and log_output is file. They need these general logs because of some special circumstances. MySQL generates about 8TB of general logs and these logs result a bigger use of the disk. Here is the tricky part: They want to remove these ge…
Convert different dates in date column to rows in SQL Server
I want to display different dates as columns from LOGDATE column. Here are the details My query: This query returns this result: Expected output format: I have multiple types of SERVICE_TYPE and SERVICE_NAME, not just the three sown in the sample. How can I get my expected output? Any help would be appreciate…
Iterate rows base on its entries column value
I need help on SQL SELECT QUERY. This is my TABLE. id | name | entries | ——————————— 1 | Jose Rizal | 1 | 2 | Raffy Tulfo | 2 | 3 | Cong …
How to compare and update an inserted value to existing value using a trigger?
I am learning triggers for the first time in SQL, and I am unsure of how to write/phrase a certain trigger. I am attempting to make a trigger that would check to see if a value within an attempted …