Not sure how to go about modelling medication taken at a point in time in a relational database. Each way I have thought of so far seems to have redundant data. Need to be able to have a user say I …
Tag: sql
MYSQL toggle enum values on each call
I want this to be like this. I have an ENUM column with 0 AND 1, i want to toggle between these two values on each query. I tried this, but it leaves the column empty. Thanks. Answer I don’t like enum for various reasons. Especially when you use it to store 0 and 1 it can be confusing, yes,
Text Qualifier syntax in PDW dwloader
I am using dwloader utility to load data into PDW. My dwloader syntax is given below: I got the data loaded into the table. But all the varchar columns have data within double ‘quotes’. My text file is commma delimited. Any idea on how to include the text qualifier in the above syntax? Answer I fi…
Getting distinct values with the highest value in a specific column
How can I get the highlighted rows from the table below in SQL? (Distinct rows based on User name with the highest Version are highlighted) In case you need plain text table: What I have so far is (works for one user) Answer this might help you : sql fiddle
Anonymous type result from sql query execution entity framework
I am using entity framework 5.0 with .net framework 4.0 code first approach. Now i know that i can run raw sql in entity framework by following It’s working perfectly but what I want is return anonymous results. For example I want only specific columns from student table like following It is not working…
Postgres constraint for unique datetime range
My table has two columns: startsAt endsAt Both hold date and time. I want to make following constraint: IF both columns are NOT NULL then range between startsAt and endsAt must not overlap with other ranges (from other rows). Answer You can keep your separate timestamp columns and still use an exclusion const…
How to get last date of month SQL Server 2008
I created a function “ufngetFirstDateOfMonth” and “ufngetLastDateOfMonth” stored in Microsoft SQL Server 2008. My purpose is to send some date into the function and it will return the first date of …
Oracle Apex column link from LOV values
Can you please advise if below is even possible. Using Oracle 11g and APEX 4.2.6. I have a data grid that brings all tasks from a master table. But show the task name via a LOV. I am trying to add …
Oracle Error PLS-00323: subprogram or cursor is declared in a package specification and must be defined in the package body
Can someone help me put my pl/sql procedure in a package? I’ve tried and I’m struggling with it: This is what I have, for my package specification: This is my package body where im running into the problems: if anyone could help me fix the errors i’d appreciate it: Answer Your header and bod…
How to give comments in SQL
I am working in SQL. What is the complete explanation for using comments in SQL, with some example code? Answer MySQL Server supports three comment styles: From a # character to the end of the line. From a — sequence to the end of the line. In MySQL, the “– ” (double-dash) comment style requires t…