Convert SQL Script to Tableau Calculated Table - sql

I'm new to Tableau and was wondering how I could create a calculated field that would be equivalent to this SQL statement:
Select studentid, min(semester)
I'm trying to get the very first recorded semester for each student.
Thanks

{fixed [StudentID]:min([Semester])}
Try using this in a calculated field.

Related

Teradata SQL Regex Question - Extract Numeric values after an Alpha

I am trying to run a select statement on a table acct id. My account ID's can have the following pattern which is the one I am having issues with: 2733R9087813964
How do I run a SELECT Statement on this column and extract only the numeric portion after the "R"?
So the result in this scenario would be: 9087813964
Any help would be appreciated.
try
SELECT Substr(ACC_ID, Position('R' IN ACC_ID) +1 )
FROM ACCOUNT

How to convert SQL script to tableau filter?

I have SQL script as below:
select name, location, max(trans_date)
From dataset
group by name, location
I want to replicate this in tableau using data source filters
Create a calculated field with this formula:
[trans_date]={FIXED [name],[location]:MAX([trans_date])}
Set it to True in the data source filters

Dax How to get distinct values from a column

This is the query I'm trying.
EVALUATE
SELECTCOLUMNS('MyTable',"col1",DISTINCT(VALUES('MyTable'[Email])))
If you are trying to simply create a new, single column table with the distinct values of an existing table, you can use the formula below.
Starting with data like this...
... simply create a new table with this formula to get a list of distinct values.
Locations = DISTINCT(Fruit[Location])
This will work:
Evaluate
VALUES('Table'[Column])

How to access SQLite table programmatically (convert string to table name)

I have a simple sqlite database with several tables like this
schedule_20140824
schedule_20140825
schedule_20140826
...
How do I generate a select statement into a table for given a date?
For example, let's say today is the 26th and I wanted my app to access today's schedule table. What is the correct way to do the following?
SELECT * FROM 'schedule_'||strftime('%Y%m%d','now');
Any advice would be appreciated. Thanks!
SQLite itself cannot generate SQL dynamically.
You have to do this in your programming language:
db.execute("SELECT * FROM schedule_" + date)

Subtract a Value from a Column and Store the results in a new Column SQL

Suppose I have a table:
names
I want to subtract 300 from its column:
salary
and store the results in a new column as:
newsalary
I know how can I have the results using:
select salary-300 as newsalary from names;
so it works but I need to store the results in a new Column and update my table I have been trying:
update names set newsalary=(salary-300);
I am just new to SQL SERVER 2008 and trying to learn it please help me is it me doing something wrong or...Thanks in advance!
You should have a column "newsalary" for your update query to run. Otherwise that query is fine.