Skip to content

Instantly share code, notes, and snippets.

@kagundajm
kagundajm / CASE-Conditional-Expression-CTE.sql
Last active March 7, 2023 14:40
A look at various options for creating crosstabs or pivot tables using PostgreSQL.
--- CASE Conditional Expression crosstab using a CTE
WITH cte AS (
SELECT salesman,
SUM(CASE order_month WHEN 1 THEN order_total ELSE 0 END) AS Jan,
SUM(CASE order_month WHEN 2 THEN order_total ELSE 0 END) AS Feb,
SUM(CASE order_month WHEN 3 THEN order_total ELSE 0 END) AS Mar,
SUM(CASE order_month WHEN 4 THEN order_total ELSE 0 END) AS Apr,
SUM(order_total) AS total
FROM
DO $$
DECLARE
r RECORD;
BEGIN
FOR r IN
(
SELECT table_name
FROM information_schema.tables
WHERE table_schema=current_schema()
)
<Target Name="NpmInstall" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(NodeModules)') ">
<Exec Command="node --version" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your project build process." />
<Message Importance="high" Text="Restoring project dependencies using 'npm'. This may take several minutes..." />
<Exec WorkingDirectory="$(ProjectDir)" Command="npm install" />
</Target>
<Target Name="NpmRunBuild" BeforeTargets="Build" DependsOnTargets="NpmInstall">
<Exec WorkingDirectory="$(AssetsRoot)" Command="npm run build" />
<PropertyGroup>
...
<AssetsRoot>$(ProjectDir)assets\</AssetsRoot>
<NodeModules>$(ProjectDir)node_modules\</NodeModules>
<WebsiteRoot>wwwroot</WebsiteRoot>
...
</PropertyGroup>
module.exports = {
future: {
// removeDeprecatedGapUtilities: true,
// purgeLayersByDefault: true,
},
purge: false,
prefix: 'tw-',
theme: {
extend: {},
},
/*@tailwind base;*/
@tailwind components;
@tailwind utilities;
module.exports = {
content: ['**/*.cshtml', '**/*.js'],
css: [ '**/*.css']
}
,"customDistStructure": {
"config": {
".css": "css",
".js": "js"
}
}
"scripts": {
"build": "parcel build assets/main.js --out-dir ./wwwroot/dist/ --no-minify --no-cache ",
"publish": "parcel build assets/main.js --out-dir ./wwwroot/dist/ --no-source-maps"
},
import 'bootstrap/dist/css/bootstrap.css';
import './css/site.css'
// Make jQuery available globally
import $ from 'jquery'
window.$ = window.jQuery = $
import 'bootstrap'
import 'jquery-validation'
import 'jquery-validation-unobtrusive'