Unable to Unpivot in MySQL

66
December 28, 2021, at 05:40 AM

I am unable to unpivot this table. I keep getting an error that two tables don't exist. I am using Microsoft SQL Server Management Studio. Here are the errors.

type            Small_Bags         Large_Bags
conventional    8603.6201171875     93.25
conventional    9408.0703125        97.4899978637695
conventional    8042.2099609375     103.139999389648
conventional    5677.39990234375    133.759994506836
conventional    5986.259765625      197.690002441406
conventional    6556.47021484375    127.440002441406

Msg 207, Level 16, State 1, Line 74 Invalid column name 'Small_Bags'. Msg 207, Level 16, State 1, Line 74 Invalid column name 'Large_Bags'

select type,Small_Bags,Large_Bags from avocado
unpivot
(
    amount 
    for category in (Small_Bags,Large_Bags)
) as unpivotexample
Answer 1

Microsoft SQL Server Management Studio implies SQL Server I believe. Your pivot converts Small_Bags,Large_Bags columns into category, amount columns. So

select type, category, amount 
from avocado
unpivot
(
    amount 
    for category in (Small_Bags,Large_Bags)
) as unpivotexample

db<>fiddle

READ ALSO
Updating ViewModel&#39;s SavedStateHandle when app in background

Updating ViewModel's SavedStateHandle when app in background

A ViewModel has a SavedStateHandleMany actions in ViewModels are async, but when something async runs when my app goes to the background, the resulting viewstate-change won't be saved in the SavedStateHandle afterwards, because the SavedStateHandle was already...

69
NodeJS video streaming to iOS doesn&#39;t work, but works on desktop Chrome and OSX safari

NodeJS video streaming to iOS doesn't work, but works on desktop Chrome and OSX safari

I am trying to make this video possible to play in Safari on iOS: https://ekgcampcom/api/videos/video1

81
Lambda-Reference by Java Reflection

Lambda-Reference by Java Reflection

I have the following code:

110
wrap a function in javascript

wrap a function in javascript

I am trying to trying to wrap all three functions in one

75