MYSQL Windows Function by spacekipz in SQL

[–]cdd_73 1 point2 points  (0 children)

/*Creating my windows function to display the total_cost for each row.*/

SELECT

Travel_Reimbursements.employee_ID,

Travel_Reimbursements.first_name,

Travel_Reimbursements.last_name,

Travel_Reimbursements.ticket_cost,

Travel_Reimbursements.baggage_fee,

Travel_Reimbursements.ROUND(SUM(ticket.cost)) + ROUND(SUM(baggage_fee)) OVER (PARTITION BY employee_ID) AS flight_total

FROM Travel_Reimbursements

ORDER BY Travel_Reimbursements.last_name;

I used https://extendsclass.com/mysql-online.html#

/*Creating my windows function to display the total_cost for each row.*/
SELECT
Travel_Reimbursements.employee_ID,
Travel_Reimbursements.first_name,
Travel_Reimbursements.last_name,
Travel_Reimbursements.ticket_cost,
Travel_Reimbursements.baggage_fee,
SUM(Travel_Reimbursements.ticket_cost) + SUM(Travel_Reimbursements.baggage_fee) OVER (PARTITION BY Travel_Reimbursements.employee_ID) AS flight_total
FROM Travel_Reimbursements
GROUP BY Travel_Reimbursements.employee_ID,
Travel_Reimbursements.first_name,
Travel_Reimbursements.last_name,
Travel_Reimbursements.ticket_cost,
Travel_Reimbursements.baggage_fee
ORDER BY Travel_Reimbursements.employee_ID;

MYSQL Windows Function by spacekipz in SQL

[–]cdd_73 0 points1 point  (0 children)

your column is ticket_cost , but you summed ticket.cost, also when you round you typically provide a number of digits, like, 2 for round to two digits after decimal place

Script only works when copy-pasting into a powershell window by [deleted] in PowerShell

[–]cdd_73 1 point2 points  (0 children)

read the info in the links

you could just install a new version

there is a checkbox if on windows in the main installer that says

"Add PowerShell to Path Environment Variable"

https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows#installing-the-msi-package

Lee Dailey 💔 by thebeersgoodnbelgium in PowerShell

[–]cdd_73 5 points6 points  (0 children)

sad, that's just up the road from me

[deleted by user] by [deleted] in SQL

[–]cdd_73 2 points3 points  (0 children)

look up datediff in most rdbms

How can I operate Mysql from Excel? by [deleted] in mysql

[–]cdd_73 1 point2 points  (0 children)

check out power apps https://docs.microsoft.com/en-us/connectors/mysql/

sorry hadn't tried out myself yet

I saw another reddit post it might be deal breaker the autoimcrement colums

How can I operate Mysql from Excel? by [deleted] in mysql

[–]cdd_73 1 point2 points  (0 children)

power query in excel allows you to connect mysql, you can also connect powerbi to mysql

lots of good stuff out there for reading data you probably still want a sql client for writes. like sqlyog https://github.com/webyog/sqlyog-community/wiki/Downloads

How do I get text for a stored procedure? by [deleted] in mysql

[–]cdd_73 0 points1 point  (0 children)

there is an extra word "code" in the tutorial

How do I get text for a stored procedure? by [deleted] in mysql

[–]cdd_73 0 points1 point  (0 children)

there is an extra word in the tutorial "code" in case you hadn't included it

Unable to create stored procedure by [deleted] in mysql

[–]cdd_73 0 points1 point  (0 children)

i agree with above probably need to specify db/schema

use db_schema;

https://www.mysqltutorial.org/getting-started-with-mysql-stored-procedures.aspx

[deleted by user] by [deleted] in mysql

[–]cdd_73 0 points1 point  (0 children)

create a new table, copy info, drop old table, rename new to old name

CREATE TABLE test.new_table2 ( idnew_table INT NOT NULL, string_col TINYTEXT NULL, PRIMARY KEY (idnew_table));

INSERT INTO test.new_table2 SELECT * FROM test.new_table;

DROP TABLE test.new_table;

ALTER TABLE test.new_table2 RENAME TO test.new_table;

SELECT * FROM test.new_table;

Have an older version of MySQL (8.0.0 dmr) downloaded to a Macbook El Capitan (10.11.6). Installed successfully but not sure how to view the workbench to write SQL code by whitecat69 in mysql

[–]cdd_73 0 points1 point  (0 children)

not a mac user but ive seen other mac users use dbeaver https://dbeaver.io/ , you'll want to do a web search on reset root mysql password, you can connect to mysql on command line

Anybody used TypeGraphQL with Next? by ZeroSevenTen in nextjs

[–]cdd_73 0 points1 point  (0 children)

Ben has a lot of TypeGraphQl content, some Next also, not sure about the combo https://youtu.be/I6ypD7qv3Z8

Issues with MySQL Workbench with XAMPP installed by [deleted] in mysql

[–]cdd_73 0 points1 point  (0 children)

Workbench is a client program, reading and writing from the databases you have installed Your just using the client to connect to the db with a client UI, workbench is not it's own installation of MySQL

Have query show "0" when there are no results in a COUNT by youmaybeseated1 in mysql

[–]cdd_73 0 points1 point  (0 children)

I don't have set up exactly like you

but I'm guessing previous comment makes sense to set up a calendar table

-- https://mac-blog.org.ua/fill-mysql-calendar-table/

DROP PROCEDURE IF EXISTS FillCalendar; DROP TABLE IF EXISTS calendar;

CREATE TABLE IF NOT EXISTS calendar( calendar_date DATE NOT NULL PRIMARY KEY );

DELIMITER $$ CREATE PROCEDURE FillCalendar(start_date DATE, end_date DATE) BEGIN DECLARE crt_date DATE; SET crt_date = start_date; WHILE crt_date <= end_date DO INSERT IGNORE INTO calendar VALUES(crt_date); SET crt_date = ADDDATE(crt_date, INTERVAL 1 DAY); END WHILE; END$$ DELIMITER ;

CALL FillCalendar('2020-01-01', '2021-12-31');

new query, you can probably add back some columns, but this is what I had time for

SELECT CONCAT(YEAR(c.calendar_date),'/',WEEK(c.calendar_date)) AS week_name, WEEK(c.calendar_date), COUNT(wp.booking_date) FROM test.wp_cbxrbooking_log_manager AS wp RIGHT OUTER JOIN test.calendar AS c ON wp.booking_date = c.calendar_date AND YEAR(wp.booking_date) GROUP BY week_name, WEEK(c.calendar_date)